mqtt module now works.
This commit is contained in:
@@ -56,11 +56,11 @@ static AQHMQTT_VALUE *_readXmlValue(AQHOME_MQTT *aqh, GWEN_XMLNODE *valueNode);
|
||||
*/
|
||||
|
||||
|
||||
AQHMQTT_DEVICE_LIST *AqHomeMqttLog_ReadSysconfDeviceFiles(AQHOME_MQTT *aqh)
|
||||
AQHMQTT_DEVICE_LIST *AqHomeMqttLog_ReadRuntimeDataDeviceFiles(AQHOME_MQTT *aqh)
|
||||
{
|
||||
GWEN_STRINGLIST *sl;
|
||||
|
||||
sl=AQH_GetListOfMatchingSysconfFiles("devices", "*.xml");
|
||||
sl=AQH_GetListOfMatchingRuntimeDataFiles("aqhome/devices", "*.xml");
|
||||
if (sl) {
|
||||
AQHMQTT_DEVICE_LIST *deviceList;
|
||||
|
||||
@@ -80,24 +80,24 @@ AQHMQTT_DEVICE_LIST *AqHomeMqttLog_ReadSysconfDeviceFiles(AQHOME_MQTT *aqh)
|
||||
|
||||
|
||||
|
||||
AQHMQTT_DEVICE_LIST *AqHomeMqttLog_ReadRuntimeDataDeviceFiles(AQHOME_MQTT *aqh)
|
||||
AQHMQTT_DEVICE_LIST *AqHomeMqttLog_ReadDataDeviceFiles(AQHOME_MQTT *aqh)
|
||||
{
|
||||
GWEN_STRINGLIST *sl;
|
||||
|
||||
sl=AQH_GetListOfMatchingRuntimeDataFiles("aqhome-mqtt/devices", "*.xml");
|
||||
sl=AQH_GetListOfMatchingDataFiles("aqhome/devices", "*.xml");
|
||||
if (sl) {
|
||||
AQHMQTT_DEVICE_LIST *deviceList;
|
||||
|
||||
deviceList=_readDeviceFiles(aqh, sl);
|
||||
GWEN_StringList_free(sl);
|
||||
if (deviceList==NULL) {
|
||||
DBG_INFO(NULL, "Error reading sysconf device files");
|
||||
DBG_INFO(NULL, "Error reading data device files");
|
||||
return NULL;
|
||||
}
|
||||
return deviceList;
|
||||
}
|
||||
else {
|
||||
DBG_INFO(NULL, "No sysconf device files");
|
||||
DBG_ERROR(NULL, "No data device files");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,10 @@ AQHMQTT_DEVICE_LIST *_readDeviceFiles(AQHOME_MQTT *aqh, const GWEN_STRINGLIST *s
|
||||
AQHMQTT_DEVICE *device;
|
||||
|
||||
device=_readDeviceFile(aqh, s);
|
||||
if (device)
|
||||
AQHMQTT_Device_List_Add(device, deviceList);
|
||||
if (device) {
|
||||
DBG_ERROR(NULL, "Adding device \"%s\" to list", AQHMQTT_Device_GetName(device));
|
||||
AQHMQTT_Device_List_Add(device, deviceList);
|
||||
}
|
||||
}
|
||||
se=GWEN_StringListEntry_Next(se);
|
||||
}
|
||||
@@ -151,15 +153,23 @@ AQHMQTT_DEVICE *_readDeviceFile(AQHOME_MQTT *aqh, const char *sFilename)
|
||||
}
|
||||
deviceNode=GWEN_XMLNode_FindFirstTag(rootNode, "device", NULL, NULL);
|
||||
if (deviceNode) {
|
||||
AQHMQTT_DEVICE *device;
|
||||
const char *driverName;
|
||||
|
||||
device=_readXmlDevice(aqh, deviceNode);
|
||||
GWEN_XMLNode_free(rootNode);
|
||||
if (device==NULL) {
|
||||
DBG_INFO(NULL, "Error reading device from XML file \"%s\" (%d)", sFilename, rv);
|
||||
return NULL;
|
||||
driverName=GWEN_XMLNode_GetProperty(deviceNode, "driver", NULL);
|
||||
if (driverName && *driverName && strcasecmp(driverName, "mqtt")==0) {
|
||||
AQHMQTT_DEVICE *device;
|
||||
|
||||
device=_readXmlDevice(aqh, deviceNode);
|
||||
GWEN_XMLNode_free(rootNode);
|
||||
if (device==NULL) {
|
||||
DBG_INFO(NULL, "Error reading device from XML file \"%s\" (%d)", sFilename, rv);
|
||||
return NULL;
|
||||
}
|
||||
return device;
|
||||
}
|
||||
else {
|
||||
DBG_INFO(NULL, "Device is not an MQTT device, ignoring");
|
||||
}
|
||||
return device;
|
||||
}
|
||||
else {
|
||||
DBG_INFO(NULL, "XML file \"%s\" does not contain a <device> element", sFilename);
|
||||
|
||||
Reference in New Issue
Block a user