aqhome-nodes: send heartbeat message to interface every 2mins.
e02 now expects this message. If for at least 10mins no such msg is received the USB interface is reset.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
|
||||
#define CONNCLEAN_INTERVAL_IN_SECS 2
|
||||
#define CONNCHECK_INTERVAL_IN_SECS 10
|
||||
#define HEARTBEAT_INTERVAL_IN_SECS 120 /* every 2mins */
|
||||
|
||||
|
||||
|
||||
@@ -133,11 +134,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
|
||||
int timeout;
|
||||
time_t timeLastConnectionCleanup;
|
||||
time_t timeLastConnCheck;
|
||||
time_t timeLastHeartbeat;
|
||||
|
||||
timeout=AQH_NodeServer_GetTimeout(aqh);
|
||||
timeStart=time(NULL);
|
||||
timeLastConnectionCleanup=time(NULL);
|
||||
timeLastConnCheck=time(NULL);
|
||||
timeLastConnectionCleanup=timeStart;
|
||||
timeLastConnCheck=timeStart;
|
||||
timeLastHeartbeat=timeStart;
|
||||
|
||||
while(!stopService) {
|
||||
time_t now;
|
||||
@@ -162,6 +165,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
|
||||
timeLastConnCheck=now;
|
||||
}
|
||||
|
||||
if (_diffInSeconds(now, timeLastHeartbeat)>HEARTBEAT_INTERVAL_IN_SECS) {
|
||||
DBG_INFO(NULL, "Sending heartbeat message");
|
||||
AQH_NodeServer_SendHeartbeat(aqh);
|
||||
timeLastHeartbeat=now;
|
||||
}
|
||||
|
||||
|
||||
if (timeout && (_diffInSeconds(now, timeStart)>timeout)) {
|
||||
DBG_INFO(NULL, "Timeout");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user