aqhome-storage now checks and parses mqtt messages and stores values in datafiles.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "./init.h"
|
||||
#include "./fini.h"
|
||||
#include "./loop.h"
|
||||
#include "./loop_mqtt.h"
|
||||
#include "./cleanup.h"
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
#define CLEANUP_INTERVAL_IN_SECS (60)
|
||||
#define WRITE_INTERVAL_IN_SECS (60)
|
||||
#define PING_INTERVAL 120
|
||||
|
||||
|
||||
|
||||
@@ -136,12 +138,14 @@ void _runService(AQHOME_STORAGE *aqh)
|
||||
time_t timeStart;
|
||||
time_t timeLastCleanup;
|
||||
time_t timeLastWrite;
|
||||
time_t timeLastPing;
|
||||
int timeout;
|
||||
|
||||
timeout=AqHomeStorage_GetTimeout(aqh);
|
||||
timeStart=time(NULL);
|
||||
timeLastCleanup=time(NULL);
|
||||
timeLastWrite=time(NULL);
|
||||
timeLastPing=time(NULL);
|
||||
|
||||
while(!stopService) {
|
||||
time_t now;
|
||||
@@ -163,6 +167,12 @@ void _runService(AQHOME_STORAGE *aqh)
|
||||
timeLastWrite=now;
|
||||
}
|
||||
|
||||
if (timeout && ((int)difftime(now, timeLastPing))>timeout) {
|
||||
DBG_INFO(NULL, "Sending ping");
|
||||
AqHomeStorage_MqttPing(aqh);
|
||||
timeLastPing=now;
|
||||
}
|
||||
|
||||
|
||||
if (timeout && ((int)difftime(now, timeStart))>timeout) {
|
||||
DBG_INFO(NULL, "Timeout");
|
||||
|
||||
Reference in New Issue
Block a user