Skip to content

Commit

Permalink
Fix DSMR version aware telegram verification
Browse files Browse the repository at this point in the history
telegrams contain a CRC starting from DSMR 4.0, not DSMR 4.2
  • Loading branch information
Pwuts authored Sep 13, 2020
1 parent 09ecfe1 commit f33f2cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Metertrekker2MQTT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void loop()
Serial.printf("Telegram length: %zu\n", read_length);

bool telegram_valid;
if (dsmr_version >= 42) { // before DSMR 4.2, telegrams did not contain a CRC tag at the end
if (dsmr_version >= 40) { // before DSMR 4.0, telegrams did not contain a CRC tag at the end
char received_crc[5];
P1.readBytes(received_crc, 4);
received_crc[4] = 0;
Expand All @@ -123,7 +123,7 @@ void loop()
}

if (telegram_valid) {
if (dsmr_version >= 42) Serial.print("Telegram valid!\r\n\n"); // can't be so sure from just counting the brackets (< DSMR 4.2)
if (dsmr_version >= 40) Serial.print("Telegram valid!\r\n\n"); // can't be so sure from just counting the brackets (< DSMR 4.0)

first_telegram = false;
last_telegram_time = millis();
Expand Down

0 comments on commit f33f2cf

Please sign in to comment.