Skip to content

Commit d743eb6

Browse files
committed
feat: more descriptive return codes, sanity checks
1 parent 5353f19 commit d743eb6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/devices/astrostart_2000.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int astrostart_2000_decode(r_device *decoder, bitbuffer_t *bitbuffer)
8282
uint8_t *bytes = bitbuffer->bb[0];
8383

8484
if (bytes[0] != (~bytes[1] & 0xff)) {
85-
return DECODE_ABORT_EARLY;
85+
return DECODE_FAIL_MIC;
8686
}
8787

8888
button = bytes[0];
@@ -97,7 +97,7 @@ static int astrostart_2000_decode(r_device *decoder, bitbuffer_t *bitbuffer)
9797
}
9898

9999
if (actual_checksum != expected_checksum) {
100-
return DECODE_ABORT_EARLY;
100+
return DECODE_FAIL_MIC;
101101
}
102102

103103
// these are not bit flags

src/devices/audiovox_car_remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ static int audiovox_decode(r_device *decoder, bitbuffer_t *bitbuffer)
6666
code = (bytes[2] << 8) | bytes[3];
6767
button = (bytes[4] >> 3) & 0xf;
6868

69-
if (id == 0 || code == 0 || button == 0) {
70-
return DECODE_ABORT_EARLY;
69+
if (id == 0 || code == 0 || button == 0 || id == 0xffff || code == 0xffff) {
70+
return DECODE_FAIL_SANITY;
7171
}
7272

7373
/* clang-format off */

src/devices/compustar_700r.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ IIIII bbbbb xxx
3434
3535
- I: 20 bit remote ID
3636
- B: 5 bit button flags
37-
- x: 3 bit unknown (always set to 111)
37+
- x: 3 bit unknown (always set to 000)
3838
3939
Format string:
4040
@@ -57,14 +57,14 @@ static int compustar_700r_decode(r_device *decoder, bitbuffer_t *bitbuffer)
5757
uint8_t *bytes = bitbuffer->bb[0];
5858

5959
if ((bytes[4] & 0x7) != 0x0) {
60-
return DECODE_ABORT_EARLY;
60+
return DECODE_FAIL_SANITY;
6161
}
6262

6363
int id = bytes[0] << 12 | bytes[1] << 4 | bytes[2] >> 4;
6464
int button = ~(bytes[2] << 1 | bytes[3] >> 7) & 0x1f;
6565

66-
if ((bytes[4] & 0x7) != 0x0 || button == 0 || id == 0) {
67-
return DECODE_ABORT_EARLY;
66+
if ((bytes[4] & 0x7) != 0x0 || button == 0 || id == 0 || id == 0xfffff) {
67+
return DECODE_FAIL_SANITY;
6868
}
6969

7070
// button flags

0 commit comments

Comments
 (0)