Skip to content

Commit

Permalink
v1.2.4 changed moment of writing to RING-files
Browse files Browse the repository at this point in the history
  • Loading branch information
mrWheel committed Apr 16, 2020
1 parent 20122af commit f0280eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DSMRloggerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions DSMRloggerAPI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
**
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion SPIFFSstuff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions processTelegram.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,6 +62,9 @@ void processTelegram()
sendMQTTData();
}

strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp);
actT = epoch(actTimestamp, strlen(actTimestamp), true); // update system time

} // processTelegram()


Expand Down

0 comments on commit f0280eb

Please sign in to comment.