diff --git a/DSMRloggerAPI.h b/DSMRloggerAPI.h index 50de352..a39e29c 100644 --- a/DSMRloggerAPI.h +++ b/DSMRloggerAPI.h @@ -230,7 +230,7 @@ String pTimestamp; DECLARE_TIMER_SEC(updateSeconds, 1, CATCH_UP_MISSED_TICKS); DECLARE_TIMER_SEC(updateDisplay, 5); DECLARE_TIMER_MIN(reconnectWiFi, 30); -DECLARE_TIMER_SEC(synchrNTP, 30); +DECLARE_TIMER_MIN(synchrNTP, 10, SKIP_MISSED_TICKS); DECLARE_TIMER_SEC(nextTelegram, 10); DECLARE_TIMER_MIN(reconnectMQTTtimer, 2); // try reconnecting cyclus timer DECLARE_TIMER_SEC(publishMQTTtimer, 60, SKIP_MISSED_TICKS); // interval time between MQTT messages diff --git a/DSMRloggerAPI.ino b/DSMRloggerAPI.ino index 7b83d2d..a7d119d 100644 --- a/DSMRloggerAPI.ino +++ b/DSMRloggerAPI.ino @@ -2,7 +2,7 @@ *************************************************************************** ** Program : DSMRloggerAPI (restAPI) */ -#define _FW_VERSION "v1.2.4 (11-04-2020)" +#define _FW_VERSION "v1.2.4 (16-04-2020)" /* ** Copyright (c) 2020 Willem Aandewiel ** @@ -12,6 +12,7 @@ Arduino-IDE settings for DSMR-logger Version 4 (ESP-12): - Board: "Generic ESP8266 Module" + - Builtin Led: "2" - Flash mode: "DOUT" | "DIO" // change only after power-off and on again! - Flash size: "4MB (FS: 2MB OAT:~1019KB)" << LET OP! 2MB SPIFFS - DebugT port: "Disabled" @@ -21,7 +22,7 @@ - Crystal Frequency: "26 MHz" - VTables: "Flash" - Flash Frequency: "40MHz" - - CPU Frequency: "80 MHz" + - CPU Frequency: "80 MHz" (or 160MHz) - Buildin Led: "2" // GPIO02 for Wemos and ESP-12 - Upload Speed: "115200" - Erase Flash: "Only Sketch" @@ -604,12 +605,12 @@ void loop () #if defined(USE_NTP_TIME) //USE_NTP if DUE(synchrNTP) //USE_NTP { - if (timeStatus() == timeNeedsSync || prevNtpHour != hour()) //USE_NTP - { - prevNtpHour = hour(); //USE_NTP + //if (timeStatus() == timeNeedsSync || prevNtpHour != hour()) //USE_NTP + //{ + //prevNtpHour = hour(); //USE_NTP setSyncProvider(getNtpTime); //USE_NTP setSyncInterval(600); //USE_NTP - } + //} } #endif //USE_NTP diff --git a/SPIFFSstuff.ino b/SPIFFSstuff.ino index 765713c..6342c81 100644 --- a/SPIFFSstuff.ino +++ b/SPIFFSstuff.ino @@ -209,7 +209,8 @@ void writeDataToFiles() recSlot = timestampToHourSlot(actTimestamp, strlen(actTimestamp)); if (Verbose1) DebugTf("HOURS: Write to slot[%02d] in %s\r\n", recSlot, HOURS_FILE); writeDataToFile(HOURS_FILE, record, recSlot, HOURS); - + writeToSysLog("HOURS: actTimestamp[%s], recSlot[%d]", actTimestamp, recSlot); + // update DAYS recSlot = timestampToDaySlot(actTimestamp, strlen(actTimestamp)); if (Verbose1) DebugTf("DAYS: Write to slot[%02d] in %s\r\n", recSlot, DAYS_FILE); diff --git a/processTelegram.ino b/processTelegram.ino index cc88b14..a55f76d 100644 --- a/processTelegram.ino +++ b/processTelegram.ino @@ -29,19 +29,22 @@ void processTelegram() strcpy(newTimestamp, DSMRdata.timestamp.c_str()); - newT = epoch(newTimestamp, strlen(newTimestamp), true); // update system time + newT = epoch(newTimestamp, strlen(newTimestamp), false); // do NOT update system time actT = epoch(actTimestamp, strlen(actTimestamp), false); // Skip first 3 telegrams .. just to settle down a bit ;-) if ((int32_t)(telegramCount - telegramErrors) < 3) { + strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp); + actT = epoch(actTimestamp, strlen(actTimestamp), true); // update system time return; } - strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp); // maar nog NIET actT!!! DebugTf("actHour[%02d] -- newHour[%02d]\r\n", hour(actT), hour(newT)); - + if (hour(actT) != hour(newT)) { + writeToSysLog("actHour[%02d] -- newHour[%02d]", hour(actT), hour(newT)); + } // has the hour changed (or the day or month) // in production testing on hour only would // suffice, but in testing I need all three @@ -59,6 +62,9 @@ void processTelegram() sendMQTTData(); } + strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp); + actT = epoch(actTimestamp, strlen(actTimestamp), true); // update system time + } // processTelegram()