started working on mqtt support in aqhome-nodes

This commit is contained in:
Martin Preuss
2025-08-03 00:56:22 +02:00
parent 8c13f9fdf7
commit 7fbc616ce4
7 changed files with 481 additions and 16 deletions

View File

@@ -36,6 +36,7 @@
#define CONNCLEAN_INTERVAL_IN_SECS 2
#define CONNCHECK_INTERVAL_IN_SECS 10
#define PING_INTERVAL_IN_SECS 120
@@ -133,11 +134,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
int timeout;
time_t timeLastConnectionCleanup;
time_t timeLastConnCheck;
time_t timeLastPingSend;
timeout=AQH_NodeServer_GetTimeout(aqh);
timeStart=time(NULL);
timeLastConnectionCleanup=time(NULL);
timeLastConnCheck=time(NULL);
timeLastPingSend=time(NULL);
while(!stopService) {
time_t now;
@@ -146,6 +149,7 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
AQH_NodeServer_HandleTtyMsgs(aqh);
AQH_NodeServer_HandleClientMsgs(aqh);
AQH_NodeServer_HandleBrokerMsgs(aqh);
AQH_NodeServer_HandleMqttMsgs(aqh);
now=time(NULL);
@@ -159,9 +163,20 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
DBG_INFO(NULL, "Check connections");
AQH_NodeServer_CheckBrokerConnection(aqh);
AQH_NodeServer_CheckTtyConnection(aqh);
AQH_NodeServer_CheckMqttConnection(aqh);
timeLastConnCheck=now;
}
if (_diffInSeconds(now, timeLastPingSend)>PING_INTERVAL_IN_SECS) {
int rv;
rv=AQH_NodeServer_SendPing(aqh);
if (rv<0) {
DBG_INFO(NULL, "Error sending PING");
}
timeLastPingSend=time(NULL);
}
if (timeout && (_diffInSeconds(now, timeStart)>timeout)) {
DBG_INFO(NULL, "Timeout");
break;