Fixed DSMR CRC check

This commit is contained in:
Gunnar Skjold
2022-12-19 18:14:12 +01:00
parent 8f057e687c
commit 43cb9a0000
4 changed files with 28 additions and 8 deletions

View File

@@ -1,16 +1,10 @@
#include "IEC6205621.h"
#include "ams/crc.h"
IEC6205621::IEC6205621(const char* p) {
if(strlen(p) < 16)
return;
String payload(p+1);
int crc_pos = payload.lastIndexOf("!");
String crc = payload.substring(crc_pos+1, crc_pos+5);
//uint16_t crc_calc = crc16_x25((uint8_t*) (payload.startsWith("/") ? p+1 : p), crc_pos);
//Serial.printf("CRC %s :: %04X\n", crc.c_str(), crc_calc);
lastUpdateMillis = millis();
listId = payload.substring(payload.startsWith("/") ? 1 : 0, payload.indexOf("\n"));