Support for LNG2 with 11 data points instead of 14

This commit is contained in:
Gunnar Skjold
2025-10-16 14:06:39 +02:00
parent 473932f1bc
commit 37431d00fc
2 changed files with 43 additions and 2 deletions

View File

@@ -12,7 +12,22 @@
#include "DataParser.h"
#include "Cosem.h"
struct Lng2Data_3p {
struct Lng2Data_3p_0b {
CosemBasic header;
CosemLongUnsigned u1;
CosemLongUnsigned u2;
CosemLongUnsigned u3;
CosemLongUnsigned i1;
CosemLongUnsigned i2;
CosemLongUnsigned i3;
CosemDLongUnsigned activeImport;
CosemDLongUnsigned activeExport;
CosemDLongUnsigned acumulatedImport;
CosemDLongUnsigned accumulatedExport;
CosemString meterId;
} __attribute__((packed));
struct Lng2Data_3p_0e {
CosemBasic header;
CosemLongUnsigned u1;
CosemLongUnsigned u2;

View File

@@ -14,7 +14,33 @@ LNG2::LNG2(AmsData& meterState, const char* payload, uint8_t useMeterType, Meter
meterType = AmsTypeLandisGyr;
this->packageTimestamp = ctx.timestamp;
Lng2Data_3p* d = (Lng2Data_3p*) payload;
Lng2Data_3p_0e* d = (Lng2Data_3p_0e*) payload;
this->l1voltage = ntohs(d->u1.data);
this->l2voltage = ntohs(d->u2.data);
this->l3voltage = ntohs(d->u3.data);
this->l1current = ntohs(d->i1.data) / 100.0;
this->l2current = ntohs(d->i2.data) / 100.0;
this->l3current = ntohs(d->i3.data) / 100.0;
this->activeImportPower = ntohl(d->activeImport.data);
this->activeExportPower = ntohl(d->activeExport.data);
this->activeImportCounter = ntohl(d->acumulatedImport.data) / 1000.0;
this->activeExportCounter = ntohl(d->accumulatedExport.data) / 1000.0;
char str[64];
uint8_t str_len = getString((CosemData*) &d->meterId, str);
if(str_len > 0) {
this->meterId = String(str);
}
listType = 3;
lastUpdateMillis = millis64();
} else if(h->length == 0x0b) {
apply(meterState);
meterType = AmsTypeLandisGyr;
this->packageTimestamp = ctx.timestamp;
Lng2Data_3p_0b* d = (Lng2Data_3p_0b*) payload;
this->l1voltage = ntohs(d->u1.data);
this->l2voltage = ntohs(d->u2.data);
this->l3voltage = ntohs(d->u3.data);