Improved mqttlog daemaon: persistent registered devices.
This commit is contained in:
@@ -95,6 +95,23 @@ int AqHomeMqtt_GetTimeout(const AQHOME_MQTT *aqh)
|
||||
|
||||
|
||||
|
||||
const char *AqHomeMqtt_GetDeviceFile(const AQHOME_MQTT *aqh)
|
||||
{
|
||||
return aqh?aqh->deviceFile:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomeMqtt_SetDeviceFile(AQHOME_MQTT *aqh, const char *s)
|
||||
{
|
||||
if (aqh) {
|
||||
free(aqh->deviceFile);
|
||||
aqh->deviceFile=s?strdup(s):NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQHMQTT_DEVICE_LIST *AqHomeMqtt_GetAvailableDeviceList(const AQHOME_MQTT *aqh)
|
||||
{
|
||||
return aqh?aqh->availableDeviceList:NULL;
|
||||
@@ -112,16 +129,59 @@ void AqHomeMqtt_SetAvailableDeviceList(AQHOME_MQTT *aqh, AQHMQTT_DEVICE_LIST *dl
|
||||
|
||||
|
||||
|
||||
void AqHomeMqtt_SetRegisteredDeviceList(AQHOME_MQTT *aqh, AQHMQTT_DEVICE_LIST *dl)
|
||||
{
|
||||
if (aqh) {
|
||||
AQHMQTT_Device_List_free(aqh->registeredDeviceList);
|
||||
aqh->registeredDeviceList=dl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQHMQTT_DEVICE *AqHomeMqtt_FindRegisteredDevice(AQHOME_MQTT *aqh, const char *wantedDeviceId)
|
||||
{
|
||||
if (aqh && aqh->registeredDeviceList)
|
||||
if (aqh && aqh->registeredDeviceList) {
|
||||
return AQHMQTT_Device_List_GetById(aqh->registeredDeviceList, wantedDeviceId);
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(NULL, "No registered devices");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomeMqtt_DumpRegisteredDevices(const AQHOME_MQTT *aqh)
|
||||
{
|
||||
if (aqh && aqh->registeredDeviceList) {
|
||||
AQHMQTT_DEVICE *device;
|
||||
|
||||
device=AQHMQTT_Device_List_First(aqh->registeredDeviceList);
|
||||
if (device) {
|
||||
fprintf(stderr, "Registered Devices:\n");
|
||||
while(device) {
|
||||
const char *sDeviceName;
|
||||
const char *sDeviceId;
|
||||
|
||||
sDeviceName=AQHMQTT_Device_GetName(device);
|
||||
sDeviceId=AQHMQTT_Device_GetId(device);
|
||||
fprintf(stderr, " %s (%s)\n", sDeviceId?sDeviceId:"<no id>", sDeviceName?sDeviceName:"<no name>");
|
||||
device=AQHMQTT_Device_List_Next(device);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No registered devices\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No registered devices\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user