aqhome: removed unused and unneeded code.
This commit is contained in:
@@ -58,13 +58,11 @@ GWEN_MSG_ENDPOINT *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
|
|||||||
const char *mqttAddress;
|
const char *mqttAddress;
|
||||||
int mqttPort;
|
int mqttPort;
|
||||||
const char *mqttClientId;
|
const char *mqttClientId;
|
||||||
const char *mqttTopicPrefix;
|
|
||||||
int mqttKeepAlive;
|
int mqttKeepAlive;
|
||||||
|
|
||||||
mqttAddress=GWEN_DB_GetCharValue(dbArgs, "mqttAddress", 0, NULL);
|
mqttAddress=GWEN_DB_GetCharValue(dbArgs, "mqttAddress", 0, NULL);
|
||||||
mqttPort=GWEN_DB_GetIntValue(dbArgs, "mqttPort", 0, 1883);
|
mqttPort=GWEN_DB_GetIntValue(dbArgs, "mqttPort", 0, 1883);
|
||||||
mqttClientId=GWEN_DB_GetCharValue(dbArgs, "mqttClientId", 0, "aqhome-mqttlog");
|
mqttClientId=GWEN_DB_GetCharValue(dbArgs, "mqttClientId", 0, "aqhome-mqttlog");
|
||||||
mqttTopicPrefix=GWEN_DB_GetCharValue(dbArgs, "mqttTopicPrefix", 0, "aqhome/sensors");
|
|
||||||
mqttKeepAlive=GWEN_DB_GetIntValue(dbArgs, "mqttKeepAlive", 0, 600);
|
mqttKeepAlive=GWEN_DB_GetIntValue(dbArgs, "mqttKeepAlive", 0, 600);
|
||||||
|
|
||||||
if (mqttAddress && *mqttAddress && mqttPort) {
|
if (mqttAddress && *mqttAddress && mqttPort) {
|
||||||
@@ -76,8 +74,6 @@ GWEN_MSG_ENDPOINT *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
|
|||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (mqttTopicPrefix && *mqttTopicPrefix)
|
|
||||||
AQH_MqttClientEndpoint_SetTopicPrefix(epMqtt, mqttTopicPrefix);
|
|
||||||
AQH_MqttClientEndpoint_SetKeepAliveTime(epMqtt, mqttKeepAlive);
|
AQH_MqttClientEndpoint_SetKeepAliveTime(epMqtt, mqttKeepAlive);
|
||||||
|
|
||||||
return epMqtt;
|
return epMqtt;
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ void _setupMqtt(AQHOMED *aqh, GWEN_DB_NODE *dbArgs)
|
|||||||
|
|
||||||
ep=AQH_MqttClientEndpoint_new(mqttClientId, mqttAddress, mqttPort, NULL, AQHOME_ENDPOINTGROUP_MQTT);
|
ep=AQH_MqttClientEndpoint_new(mqttClientId, mqttAddress, mqttPort, NULL, AQHOME_ENDPOINTGROUP_MQTT);
|
||||||
AqHomed_SetMqttTopicPrefix(aqh, mqttTopicPrefix);
|
AqHomed_SetMqttTopicPrefix(aqh, mqttTopicPrefix);
|
||||||
AQH_MqttClientEndpoint_SetTopicPrefix(ep, mqttTopicPrefix);
|
|
||||||
AQH_MqttClientEndpoint_SetKeepAliveTime(ep, mqttKeepAlive);
|
AQH_MqttClientEndpoint_SetKeepAliveTime(ep, mqttKeepAlive);
|
||||||
|
|
||||||
GWEN_MsgEndpoint_Tree2_AddChild(aqh->rootEndpoint, ep);
|
GWEN_MsgEndpoint_Tree2_AddChild(aqh->rootEndpoint, ep);
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
|
|
||||||
xep=(AQH_ENDPOINT_MQTT*) p;
|
xep=(AQH_ENDPOINT_MQTT*) p;
|
||||||
free(xep->clientId);
|
free(xep->clientId);
|
||||||
free(xep->topicPrefix);
|
|
||||||
GWEN_FREE_OBJECT(xep);
|
GWEN_FREE_OBJECT(xep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,36 +102,6 @@ void AQH_MqttEndpoint_SetClientId(GWEN_MSG_ENDPOINT *ep, const char *s)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char *AQH_MqttEndpoint_GetTopicPrefix(const GWEN_MSG_ENDPOINT *ep)
|
|
||||||
{
|
|
||||||
if (ep) {
|
|
||||||
AQH_ENDPOINT_MQTT *xep;
|
|
||||||
|
|
||||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_MQTT, ep);
|
|
||||||
if (xep) {
|
|
||||||
return xep->topicPrefix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQH_MqttEndpoint_SetTopicPrefix(GWEN_MSG_ENDPOINT *ep, const char *s)
|
|
||||||
{
|
|
||||||
if (ep) {
|
|
||||||
AQH_ENDPOINT_MQTT *xep;
|
|
||||||
|
|
||||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_MQTT, ep);
|
|
||||||
if (xep) {
|
|
||||||
free(xep->topicPrefix);
|
|
||||||
xep->topicPrefix=s?strdup(s):NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t AQH_MqttEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep)
|
uint16_t AQH_MqttEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep)
|
||||||
{
|
{
|
||||||
if (ep) {
|
if (ep) {
|
||||||
@@ -255,67 +224,3 @@ GWEN_MSG *AQH_MqttEndpoint_CreateMsgConnect(GWEN_MSG_ENDPOINT *ep)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishDouble(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, double v)
|
|
||||||
{
|
|
||||||
char numBuf[16];
|
|
||||||
|
|
||||||
snprintf(numBuf, sizeof(numBuf)-1, "%f", v);
|
|
||||||
numBuf[sizeof(numBuf)-1]=0;
|
|
||||||
return AQH_MqttEndpoint_CreateMsgPublishString(ep, uid, valueId, valuePath, numBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishInt(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, int v)
|
|
||||||
{
|
|
||||||
char numBuf[16];
|
|
||||||
|
|
||||||
snprintf(numBuf, sizeof(numBuf)-1, "%d", v);
|
|
||||||
numBuf[sizeof(numBuf)-1]=0;
|
|
||||||
return AQH_MqttEndpoint_CreateMsgPublishString(ep, uid, valueId, valuePath, numBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishString(GWEN_MSG_ENDPOINT *ep,
|
|
||||||
uint32_t uid,
|
|
||||||
int valueId,
|
|
||||||
const char *valuePath,
|
|
||||||
const char *v)
|
|
||||||
{
|
|
||||||
if (ep) {
|
|
||||||
AQH_ENDPOINT_MQTT *xep;
|
|
||||||
|
|
||||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_MQTT, ep);
|
|
||||||
if (xep) {
|
|
||||||
GWEN_BUFFER *bufTopic;
|
|
||||||
GWEN_MSG *pubMsg;
|
|
||||||
|
|
||||||
bufTopic=GWEN_Buffer_new(0, 64, 0, 1);
|
|
||||||
if (valueId>0)
|
|
||||||
GWEN_Buffer_AppendArgs(bufTopic, "%s/%08x/%d/%s",
|
|
||||||
xep->topicPrefix,
|
|
||||||
uid,
|
|
||||||
valueId,
|
|
||||||
valuePath);
|
|
||||||
else
|
|
||||||
GWEN_Buffer_AppendArgs(bufTopic, "%s/%08x/%s",
|
|
||||||
xep->topicPrefix,
|
|
||||||
uid,
|
|
||||||
valuePath);
|
|
||||||
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "MQTT PUBLISH %s: %s", GWEN_Buffer_GetStart(bufTopic), v);
|
|
||||||
pubMsg=AQH_PublishMqttMsg_new(0, 0, GWEN_Buffer_GetStart(bufTopic), (const uint8_t*) v, strlen(v));
|
|
||||||
GWEN_Buffer_free(bufTopic);
|
|
||||||
if (pubMsg==NULL) {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "here");
|
|
||||||
}
|
|
||||||
return pubMsg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,6 @@ AQHOME_API void AQH_MqttEndpoint_Extend(GWEN_MSG_ENDPOINT *ep);
|
|||||||
AQHOME_API const char *AQH_MqttEndpoint_GetClientId(const GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API const char *AQH_MqttEndpoint_GetClientId(const GWEN_MSG_ENDPOINT *ep);
|
||||||
AQHOME_API void AQH_MqttEndpoint_SetClientId(GWEN_MSG_ENDPOINT *ep, const char *s);
|
AQHOME_API void AQH_MqttEndpoint_SetClientId(GWEN_MSG_ENDPOINT *ep, const char *s);
|
||||||
|
|
||||||
AQHOME_API const char *AQH_MqttEndpoint_GetTopicPrefix(const GWEN_MSG_ENDPOINT *ep);
|
|
||||||
AQHOME_API void AQH_MqttEndpoint_SetTopicPrefix(GWEN_MSG_ENDPOINT *ep, const char *s);
|
|
||||||
|
|
||||||
AQHOME_API uint16_t AQH_MqttEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API uint16_t AQH_MqttEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep);
|
||||||
|
|
||||||
AQHOME_API uint16_t AQH_MqttEndpoint_GetKeepAliveTime(const GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API uint16_t AQH_MqttEndpoint_GetKeepAliveTime(const GWEN_MSG_ENDPOINT *ep);
|
||||||
@@ -41,22 +38,6 @@ AQHOME_API void AQH_MqttEndpoint_SetKeepAliveTime(GWEN_MSG_ENDPOINT *ep, uint16_
|
|||||||
|
|
||||||
|
|
||||||
AQHOME_API GWEN_MSG *AQH_MqttEndpoint_CreateMsgConnect(GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API GWEN_MSG *AQH_MqttEndpoint_CreateMsgConnect(GWEN_MSG_ENDPOINT *ep);
|
||||||
AQHOME_API GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishString(GWEN_MSG_ENDPOINT *ep,
|
|
||||||
uint32_t uid,
|
|
||||||
int valueId,
|
|
||||||
const char *valuePath,
|
|
||||||
const char *v);
|
|
||||||
AQHOME_API GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishDouble(GWEN_MSG_ENDPOINT *ep,
|
|
||||||
uint32_t uid,
|
|
||||||
int valueId,
|
|
||||||
const char *valuePath,
|
|
||||||
double v);
|
|
||||||
AQHOME_API GWEN_MSG *AQH_MqttEndpoint_CreateMsgPublishInt(GWEN_MSG_ENDPOINT *ep,
|
|
||||||
uint32_t uid,
|
|
||||||
int valueId,
|
|
||||||
const char *valuePath,
|
|
||||||
int v);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
typedef struct AQH_ENDPOINT_MQTT AQH_ENDPOINT_MQTT;
|
typedef struct AQH_ENDPOINT_MQTT AQH_ENDPOINT_MQTT;
|
||||||
struct AQH_ENDPOINT_MQTT {
|
struct AQH_ENDPOINT_MQTT {
|
||||||
char *clientId;
|
char *clientId;
|
||||||
char *topicPrefix;
|
|
||||||
uint16_t lastPacketId;
|
uint16_t lastPacketId;
|
||||||
uint16_t keepAliveTime;
|
uint16_t keepAliveTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ static void _checkSocketsWhenConnected(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT
|
|||||||
|
|
||||||
|
|
||||||
GWEN_MSG_ENDPOINT *AQH_MqttClientEndpoint_new(const char *clientId,
|
GWEN_MSG_ENDPOINT *AQH_MqttClientEndpoint_new(const char *clientId,
|
||||||
const char *host, int port,
|
const char *host, int port,
|
||||||
const char *name, int groupId)
|
const char *name, int groupId)
|
||||||
{
|
{
|
||||||
GWEN_MSG_ENDPOINT *ep;
|
GWEN_MSG_ENDPOINT *ep;
|
||||||
GWEN_MSG_ENDPOINT *epChild;
|
GWEN_MSG_ENDPOINT *epChild;
|
||||||
@@ -155,34 +155,6 @@ uint16_t AQH_MqttClientEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char *AQH_MqttClientEndpoint_GetTopicPrefix(const GWEN_MSG_ENDPOINT *ep)
|
|
||||||
{
|
|
||||||
if (ep) {
|
|
||||||
GWEN_MSG_ENDPOINT *epChild;
|
|
||||||
|
|
||||||
epChild=GWEN_MsgEndpoint_Tree2_GetFirstChild(ep);
|
|
||||||
if (epChild)
|
|
||||||
return AQH_MqttEndpoint_GetTopicPrefix(epChild);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQH_MqttClientEndpoint_SetTopicPrefix(GWEN_MSG_ENDPOINT *ep, const char *s)
|
|
||||||
{
|
|
||||||
if (ep) {
|
|
||||||
GWEN_MSG_ENDPOINT *epChild;
|
|
||||||
|
|
||||||
epChild=GWEN_MsgEndpoint_Tree2_GetFirstChild(ep);
|
|
||||||
if (epChild)
|
|
||||||
AQH_MqttEndpoint_SetTopicPrefix(epChild, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _addSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
|
void _addSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
|
||||||
|
|||||||
@@ -23,18 +23,14 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
AQHOME_API GWEN_MSG_ENDPOINT *AQH_MqttClientEndpoint_new(const char *clientId,
|
AQHOME_API GWEN_MSG_ENDPOINT *AQH_MqttClientEndpoint_new(const char *clientId,
|
||||||
const char *host, int port,
|
const char *host, int port,
|
||||||
const char *name, int groupId);
|
const char *name, int groupId);
|
||||||
|
|
||||||
AQHOME_API uint16_t AQH_MqttClientEndpoint_GetKeepAliveTime(const GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API uint16_t AQH_MqttClientEndpoint_GetKeepAliveTime(const GWEN_MSG_ENDPOINT *ep);
|
||||||
AQHOME_API void AQH_MqttClientEndpoint_SetKeepAliveTime(GWEN_MSG_ENDPOINT *ep, uint16_t i);
|
AQHOME_API void AQH_MqttClientEndpoint_SetKeepAliveTime(GWEN_MSG_ENDPOINT *ep, uint16_t i);
|
||||||
|
|
||||||
AQHOME_API uint16_t AQH_MqttClientEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API uint16_t AQH_MqttClientEndpoint_GetNextPacketId(const GWEN_MSG_ENDPOINT *ep);
|
||||||
|
|
||||||
AQHOME_API const char *AQH_MqttClientEndpoint_GetTopicPrefix(const GWEN_MSG_ENDPOINT *ep);
|
|
||||||
AQHOME_API void AQH_MqttClientEndpoint_SetTopicPrefix(GWEN_MSG_ENDPOINT *ep, const char *s);
|
|
||||||
|
|
||||||
|
|
||||||
AQHOME_API int AQH_MqttClientEndpoint_StartConnect(GWEN_MSG_ENDPOINT *ep);
|
AQHOME_API int AQH_MqttClientEndpoint_StartConnect(GWEN_MSG_ENDPOINT *ep);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user