From d40a466599d34195679c618c7f222ce10b2e373e Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Mon, 9 Oct 2023 04:01:45 +0200 Subject: [PATCH] Removed assumption regarding null-bytes --- src/devices/bresser_leakage.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/devices/bresser_leakage.c b/src/devices/bresser_leakage.c index e7634e600..c24bff809 100644 --- a/src/devices/bresser_leakage.c +++ b/src/devices/bresser_leakage.c @@ -78,7 +78,6 @@ static int bresser_leakage_decode(r_device *decoder, bitbuffer_t *bitbuffer) int alarm; int no_alarm; int decode_ok; - uint8_t null_bytes; if (bitbuffer->num_rows != 1 || bitbuffer->bits_per_row[0] < 160 @@ -122,19 +121,10 @@ static int bresser_leakage_decode(r_device *decoder, bitbuffer_t *bitbuffer) alarm = ((msg[7] & 0x80) == 0x80) ? 1 : 0; no_alarm = ((msg[7] & 0x40) == 0x40) ? 1 : 0; - null_bytes = msg[7] & 0xF; - - for (int i=8; i<=15; i++) { - null_bytes |= msg[i]; - } - - // The parity/checksum/digest algorithm is currently unknown. - // We apply some heuristics to validate that the message is really from - // a water leakage sensor. + // Sanity checks decode_ok = (s_type == SENSOR_TYPE_LEAKAGE) && (alarm != no_alarm) && - (chan != 0) && - (null_bytes == 0); + (chan != 0); if (!decode_ok) return 0;