-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
audiovox_car_remote.c
104 lines (79 loc) · 2.58 KB
/
audiovox_car_remote.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/** @file
Audiovox - Car Remote.
Copyright (C) 2023 Ethan Halsall
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
/** @fn int audiovox_decode(r_device *decoder, bitbuffer_t *bitbuffer)
Audiovox - Car Remote
Manufacturer:
- Audiovox
Supported Models:
- ATCD-1
- AVX1BS4, AVX-1BS4 (FCC ID ELVATCC)
- A1BTX (FCC ID ELVATFE)
- 105BP (FCC ID ELVATJA)
Data structure:
Audiovox Type 4 and Code Alarm Type 7 Transmitters
Transmitter uses a rolling code that changes between each button press.
The same code is continuously repeated while button is held down.
On some models, multiple buttons can be pressed to set multiple button flags.
Data layout:
IIII CCCC X B
- I: 16 bit ID
- C: 16 bit rolling code, likely encrypted using symmetric encryption
- X: 1 bit unknown, possibly a parity for the decoded rolling code
- B: 4 bit flags indicating button(s) pressed
Format string:
ID: hhhh CODE: hhhh UNKNOWN: x BUTTON: bbbb
*/
#include "decoder.h"
static int audiovox_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
int id = 0;
int code = 0;
int button = 0;
if (bitbuffer->bits_per_row[0] != 37) {
return DECODE_ABORT_LENGTH;
}
if (bitbuffer->num_rows != 1) {
return DECODE_ABORT_EARLY;
}
uint8_t *bytes = bitbuffer->bb[0];
id = (bytes[0] << 8) | bytes[1];
code = (bytes[2] << 8) | bytes[3];
button = (bytes[4] >> 3) & 0xf;
if (id == 0 || code == 0 || button == 0 || id == 0xffff || code == 0xffff) {
return DECODE_FAIL_SANITY;
}
/* clang-format off */
data_t *data = data_make(
"model", "model", DATA_STRING, "Audiovox-CarRemote",
"id", "device-id", DATA_INT, id,
"code", "code", DATA_INT, code,
"button", "button", DATA_INT, button,
NULL);
/* clang-format on */
decoder_output_data(decoder, data);
return 1;
}
static char const *const output_fields[] = {
"model",
"id",
"code",
"button",
NULL,
};
r_device const audiovox_car_remote = {
.name = "Audiovox car remote",
.modulation = OOK_PULSE_PWM,
.short_width = 500,
.long_width = 945,
.reset_limit = 20000,
.gap_limit = 4050,
.sync_width = 2000,
.decode_fn = &audiovox_decode,
.fields = output_fields,
};