From 61d23ab453f36788806bf69730f3b1dce712346a Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Tue, 2 Apr 2024 11:43:45 +0200 Subject: [PATCH] Fixed LNG 0 values --- src/LNG.cpp | 3 ++- src/LNG.h | 2 +- src/LNG2.cpp | 3 ++- src/LNG2.h | 2 +- src/PassiveMeterCommunicator.cpp | 8 ++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/LNG.cpp b/src/LNG.cpp index 564e469a..e129071c 100644 --- a/src/LNG.cpp +++ b/src/LNG.cpp @@ -9,9 +9,10 @@ #include "ntohll.h" #include "Uptime.h" -LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { +LNG::LNG(AmsData& meterState, const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { LngHeader* h = (LngHeader*) payload; if(h->tag == CosemTypeStructure && h->arrayTag == CosemTypeArray) { + apply(meterState); meterType = AmsTypeLandisGyr; this->packageTimestamp = ctx.timestamp; diff --git a/src/LNG.h b/src/LNG.h index 07806f6d..d84e00ec 100644 --- a/src/LNG.h +++ b/src/LNG.h @@ -31,7 +31,7 @@ struct LngObisDescriptor { class LNG : public AmsData { public: - LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger); + LNG(AmsData& meterState, const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger); uint64_t getNumber(CosemData* item); }; diff --git a/src/LNG2.cpp b/src/LNG2.cpp index b4ae6159..b0202b49 100644 --- a/src/LNG2.cpp +++ b/src/LNG2.cpp @@ -7,9 +7,10 @@ #include "LNG2.h" #include "Uptime.h" -LNG2::LNG2(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { +LNG2::LNG2(AmsData& meterState, const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger) { CosemBasic* h = (CosemBasic*) payload; if(h->length == 0x0e) { + apply(meterState); meterType = AmsTypeLandisGyr; this->packageTimestamp = ctx.timestamp; diff --git a/src/LNG2.h b/src/LNG2.h index 23158a40..7ef3eeef 100644 --- a/src/LNG2.h +++ b/src/LNG2.h @@ -33,7 +33,7 @@ struct Lng2Data_3p { class LNG2 : public AmsData { public: - LNG2(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger); + LNG2(AmsData& meterState, const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, RemoteDebug* debugger); private: uint8_t getString(CosemData* item, char* target); diff --git a/src/PassiveMeterCommunicator.cpp b/src/PassiveMeterCommunicator.cpp index b6a44d5f..d29ef777 100644 --- a/src/PassiveMeterCommunicator.cpp +++ b/src/PassiveMeterCommunicator.cpp @@ -213,8 +213,8 @@ AmsData* PassiveMeterCommunicator::getData(AmsData& meterState) { // Rudimentary detector for L&G proprietary format, this is terrible code... Fix later if(payload[0] == CosemTypeStructure && payload[2] == CosemTypeArray && payload[1] == payload[3]) { if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("LNG\n")); - LNG lngData = LNG(payload, meterState.getMeterType(), &meterConfig, ctx, debugger); - if(lngData.getListType() >= 3) { + LNG lngData = LNG(meterState, payload, meterState.getMeterType(), &meterConfig, ctx, debugger); + if(lngData.getListType() >= 1) { data = new AmsData(); data->apply(meterState); data->apply(lngData); @@ -228,8 +228,8 @@ AmsData* PassiveMeterCommunicator::getData(AmsData& meterState) { payload[17] == CosemTypeLongUnsigned ) { if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("LNG2\n")); - LNG2 lngData = LNG2(payload, meterState.getMeterType(), &meterConfig, ctx, debugger); - if(lngData.getListType() >= 3) { + LNG2 lngData = LNG2(meterState, payload, meterState.getMeterType(), &meterConfig, ctx, debugger); + if(lngData.getListType() >= 1) { data = new AmsData(); data->apply(meterState); data->apply(lngData);