From 61c5500fdd860566403e0f41412db175699fe5f2 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Thu, 31 Aug 2023 09:18:48 +0200 Subject: [PATCH] Fixed red HAN after 49.7 days --- lib/AmsData/include/AmsData.h | 6 +++--- src/IEC6205621.cpp | 3 ++- src/IEC6205675.cpp | 11 ++++++----- src/LNG.cpp | 3 ++- src/LNG2.cpp | 3 ++- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/AmsData/include/AmsData.h b/lib/AmsData/include/AmsData.h index 61d07805..b864a2bc 100644 --- a/lib/AmsData/include/AmsData.h +++ b/lib/AmsData/include/AmsData.h @@ -22,7 +22,7 @@ public: void apply(AmsData& other); - unsigned long getLastUpdateMillis(); + uint64_t getLastUpdateMillis(); time_t getPackageTimestamp(); @@ -73,8 +73,8 @@ public: void setLastError(int8_t); protected: - unsigned long lastUpdateMillis = 0; - unsigned long lastList2 = 0; + uint64_t lastUpdateMillis = 0; + uint64_t lastList2 = 0; uint8_t listType = 0, meterType = AmsTypeUnknown; time_t packageTimestamp = 0; String listId = "", meterId = "", meterModel = ""; diff --git a/src/IEC6205621.cpp b/src/IEC6205621.cpp index 79def1a5..0d0c7851 100644 --- a/src/IEC6205621.cpp +++ b/src/IEC6205621.cpp @@ -1,4 +1,5 @@ #include "IEC6205621.h" +#include "Uptime.h" IEC6205621::IEC6205621(const char* p, Timezone* tz) { if(strlen(p) < 16) @@ -6,7 +7,7 @@ IEC6205621::IEC6205621(const char* p, Timezone* tz) { String payload(p+1); - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); listId = payload.substring(payload.startsWith("/") ? 1 : 0, payload.indexOf("\n")); if(listId.startsWith(F("ADN"))) { diff --git a/src/IEC6205675.cpp b/src/IEC6205675.cpp index c35fe360..780af2ea 100644 --- a/src/IEC6205675.cpp +++ b/src/IEC6205675.cpp @@ -2,6 +2,7 @@ #include "lwip/def.h" #include "Timezone.h" #include "ntohll.h" +#include "Uptime.h" IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx) { float val; @@ -127,7 +128,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo reactiveExportCounter = ntohl(data->dlu.data) / 1000.0; } - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } else if(listId.startsWith("ISK")) { // Iskra special case this->listId = listId; meterType = AmsTypeIskra; @@ -181,7 +182,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo data = getCosemDataAt(idx++, ((char *) (d))); l3activeExportPower = ntohl(data->dlu.data); - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } else if(data->base.length == 0x0C) { listType = 3; idx += 4; @@ -199,7 +200,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo data = getCosemDataAt(idx++, ((char *) (d))); reactiveExportCounter = ntohl(data->dlu.data) / 1000.0; - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } } } else if(useMeterType == AmsTypeKaifa && data->base.type == CosemTypeDLongUnsigned) { @@ -207,7 +208,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo listType = 1; meterType = AmsTypeKaifa; activeImportPower = ntohl(data->dlu.data); - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } // Kaifa end } else { @@ -451,7 +452,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo } } - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } if(meterConfig->wattageMultiplier > 0) { diff --git a/src/LNG.cpp b/src/LNG.cpp index e536da50..faa153ea 100644 --- a/src/LNG.cpp +++ b/src/LNG.cpp @@ -1,6 +1,7 @@ #include "LNG.h" #include "lwip/def.h" #include "ntohll.h" +#include "Uptime.h" LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { LngHeader* h = (LngHeader*) payload; @@ -117,7 +118,7 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da data += 3; } - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } } } diff --git a/src/LNG2.cpp b/src/LNG2.cpp index d7d85c41..7640954c 100644 --- a/src/LNG2.cpp +++ b/src/LNG2.cpp @@ -1,4 +1,5 @@ #include "LNG2.h" +#include "Uptime.h" LNG2::LNG2(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { CosemBasic* h = (CosemBasic*) payload; @@ -26,7 +27,7 @@ LNG2::LNG2(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, this->meterId = String(str); } listType = 3; - lastUpdateMillis = millis(); + lastUpdateMillis = millis64(); } }