119 lines
2.1 KiB
C
119 lines
2.1 KiB
C
/****************************************************************************
|
|
* This file is part of the project AqHome.
|
|
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
|
*
|
|
* The license for this file can be found in the file COPYING which you
|
|
* should have received along with this file.
|
|
****************************************************************************/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
|
|
#include "./aqhome_mqtt_p.h"
|
|
#include "aqhome/ipc/endpoint_ipc.h"
|
|
#include "aqhome/ipc/endpoint_ipcclient.h"
|
|
#include "aqhome/mqtt/endpoint_mqttc.h"
|
|
#include "aqhome/mqtt/msg_mqtt_publish.h"
|
|
|
|
#include <gwenhywfar/misc.h>
|
|
#include <gwenhywfar/debug.h>
|
|
|
|
|
|
|
|
|
|
|
|
AQHOME_MQTT *AqHomeMqtt_new(void)
|
|
{
|
|
AQHOME_MQTT *aqh;
|
|
|
|
GWEN_NEW_OBJECT(AQHOME_MQTT, aqh);
|
|
|
|
return aqh;
|
|
}
|
|
|
|
|
|
|
|
void AqHomeMqtt_free(AQHOME_MQTT *aqh)
|
|
{
|
|
if (aqh) {
|
|
AQHMQTT_Device_List_free(aqh->availableDeviceList);
|
|
AQHMQTT_Device_List_free(aqh->registeredDeviceList);
|
|
GWEN_MsgEndpoint_free(aqh->rootEndpoint);
|
|
GWEN_DB_Group_free(aqh->dbArgs);
|
|
free(aqh->pidFile);
|
|
|
|
GWEN_FREE_OBJECT(aqh);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GWEN_MSG_ENDPOINT *AqHomeMqtt_GetBrokerEndpoint(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?(aqh->brokerEndpoint):NULL;
|
|
}
|
|
|
|
|
|
|
|
GWEN_MSG_ENDPOINT *AqHomeMqtt_GetMqttEndpoint(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?(aqh->mqttEndpoint):NULL;
|
|
}
|
|
|
|
|
|
|
|
GWEN_DB_NODE *AqHomeMqtt_GetDbArgs(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?(aqh->dbArgs):NULL;
|
|
}
|
|
|
|
|
|
|
|
const char *AqHomeMqtt_GetPidFile(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?aqh->pidFile:NULL;
|
|
}
|
|
|
|
|
|
|
|
void AqHomeMqtt_SetPidFile(AQHOME_MQTT *aqh, const char *s)
|
|
{
|
|
if (aqh) {
|
|
free(aqh->pidFile);
|
|
aqh->pidFile=s?strdup(s):NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int AqHomeMqtt_GetTimeout(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?aqh->timeout:0;
|
|
}
|
|
|
|
|
|
|
|
AQHMQTT_DEVICE_LIST *AqHomeMqtt_GetAvailableDeviceList(const AQHOME_MQTT *aqh)
|
|
{
|
|
return aqh?aqh->availableDeviceList:NULL;
|
|
}
|
|
|
|
|
|
|
|
void AqHomeMqtt_SetAvailableDeviceList(AQHOME_MQTT *aqh, AQHMQTT_DEVICE_LIST *dl)
|
|
{
|
|
if (aqh) {
|
|
AQHMQTT_Device_List_free(aqh->availableDeviceList);
|
|
aqh->availableDeviceList=dl;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|