From d743eb6abb2003151d6b24f2a0202a916ed99728 Mon Sep 17 00:00:00 2001 From: Ethan Halsall Date: Mon, 25 Dec 2023 10:04:17 -0600 Subject: [PATCH] feat: more descriptive return codes, sanity checks --- src/devices/astrostart_2000.c | 4 ++-- src/devices/audiovox_car_remote.c | 4 ++-- src/devices/compustar_700r.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/devices/astrostart_2000.c b/src/devices/astrostart_2000.c index 2be157f1a..7fb3a0abb 100644 --- a/src/devices/astrostart_2000.c +++ b/src/devices/astrostart_2000.c @@ -82,7 +82,7 @@ static int astrostart_2000_decode(r_device *decoder, bitbuffer_t *bitbuffer) uint8_t *bytes = bitbuffer->bb[0]; if (bytes[0] != (~bytes[1] & 0xff)) { - return DECODE_ABORT_EARLY; + return DECODE_FAIL_MIC; } button = bytes[0]; @@ -97,7 +97,7 @@ static int astrostart_2000_decode(r_device *decoder, bitbuffer_t *bitbuffer) } if (actual_checksum != expected_checksum) { - return DECODE_ABORT_EARLY; + return DECODE_FAIL_MIC; } // these are not bit flags diff --git a/src/devices/audiovox_car_remote.c b/src/devices/audiovox_car_remote.c index bc15814d9..1033ad42a 100644 --- a/src/devices/audiovox_car_remote.c +++ b/src/devices/audiovox_car_remote.c @@ -66,8 +66,8 @@ static int audiovox_decode(r_device *decoder, bitbuffer_t *bitbuffer) code = (bytes[2] << 8) | bytes[3]; button = (bytes[4] >> 3) & 0xf; - if (id == 0 || code == 0 || button == 0) { - return DECODE_ABORT_EARLY; + if (id == 0 || code == 0 || button == 0 || id == 0xffff || code == 0xffff) { + return DECODE_FAIL_SANITY; } /* clang-format off */ diff --git a/src/devices/compustar_700r.c b/src/devices/compustar_700r.c index 1eb334629..d6644ee74 100644 --- a/src/devices/compustar_700r.c +++ b/src/devices/compustar_700r.c @@ -34,7 +34,7 @@ IIIII bbbbb xxx - I: 20 bit remote ID - B: 5 bit button flags -- x: 3 bit unknown (always set to 111) +- x: 3 bit unknown (always set to 000) Format string: @@ -57,14 +57,14 @@ static int compustar_700r_decode(r_device *decoder, bitbuffer_t *bitbuffer) uint8_t *bytes = bitbuffer->bb[0]; if ((bytes[4] & 0x7) != 0x0) { - return DECODE_ABORT_EARLY; + return DECODE_FAIL_SANITY; } int id = bytes[0] << 12 | bytes[1] << 4 | bytes[2] >> 4; int button = ~(bytes[2] << 1 | bytes[3] >> 7) & 0x1f; - if ((bytes[4] & 0x7) != 0x0 || button == 0 || id == 0) { - return DECODE_ABORT_EARLY; + if ((bytes[4] & 0x7) != 0x0 || button == 0 || id == 0 || id == 0xfffff) { + return DECODE_FAIL_SANITY; } // button flags