mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
fix watch for CRC Rx errors
This commit is contained in:
@@ -165,17 +165,18 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
|||||||
|
|
||||||
// validate the CRC
|
// validate the CRC
|
||||||
uint8_t crc = calculate_crc(data, length - 1);
|
uint8_t crc = calculate_crc(data, length - 1);
|
||||||
|
if (data[length - 1] != crc) {
|
||||||
if ((data[length - 1] != crc) && (EMSESP::watch() != EMSESP::Watch::WATCH_OFF)) {
|
|
||||||
LOG_ERROR(F("Rx: %s %s(CRC %02X != %02X)%s"), Helpers::data_to_hex(data, length).c_str(), COLOR_RED, data[length - 1], crc, COLOR_RESET);
|
|
||||||
increment_telegram_error_count();
|
increment_telegram_error_count();
|
||||||
|
if (EMSESP::watch() != EMSESP::Watch::WATCH_OFF) {
|
||||||
|
LOG_ERROR(F("Rx: %s %s(CRC %02X != %02X)%s"), Helpers::data_to_hex(data, length).c_str(), COLOR_RED, data[length - 1], crc, COLOR_RESET);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// since it's a valid telegram, work out the ems mask
|
// since it's a valid telegram, work out the ems mask
|
||||||
// we check the 1st byte, which assumed is the src ID and see if the MSB (8th bit) is set
|
// we check the 1st byte, which assumed is the src ID and see if the MSB (8th bit) is set
|
||||||
// this is used to identify if the protocol should be Junkers/HT3 or Buderus
|
// this is used to identify if the protocol should be Junkers/HT3 or Buderus
|
||||||
// this only happens once with the first rx telegram is processed
|
// this only happens once with the first valid rx telegram is processed
|
||||||
if (ems_mask() == EMS_MASK_UNSET) {
|
if (ems_mask() == EMS_MASK_UNSET) {
|
||||||
ems_mask(data[0]);
|
ems_mask(data[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user