3 static int waveman_callback(bitbuffer_t *bitbuffer) {
4 uint8_t *b = bitbuffer->bb[0];
5 /* Two bits map to 2 states, 0 1 -> 0 and 1 1 -> 1 */
11 /* @todo iterate through all rows */
13 /* Reject codes of wrong length */
14 if ( 24 != bitbuffer->bits_per_row[0])
18 * Catch the case triggering false positive for other transmitters.
19 * example: Brennstuhl RCS 2044SN
20 * @todo is this message valid at all??? if not then put more validation below
21 * instead of this special case
28 /* Test if the bit stream conforms to the rule of every odd bit being set to one */
29 if (((b[0]&0x55)==0x55) && ((b[1]&0x55)==0x55) && ((b[2]&0x55)==0x55) && ((b[3]&0x55)==0x00)) {
30 /* Extract data from the bit stream */
31 for (i=0 ; i<3 ; i++) {
32 nb[i] |= ((b[i]&0xC0)==0xC0) ? 0x00 : 0x01;
33 nb[i] |= ((b[i]&0x30)==0x30) ? 0x00 : 0x02;
34 nb[i] |= ((b[i]&0x0C)==0x0C) ? 0x00 : 0x04;
35 nb[i] |= ((b[i]&0x03)==0x03) ? 0x00 : 0x08;
38 id_str[0] = 'A'+nb[0];
40 data = data_make("model", NULL, DATA_STRING, "Waveman Switch Transmitter",
41 "id", NULL, DATA_STRING, id_str,
42 "channel", NULL, DATA_INT, (nb[1]>>2)+1,
43 "button", NULL, DATA_INT, (nb[1]&3)+1,
44 "state", NULL, DATA_STRING, (nb[2]==0xe) ? "on" : "off",
46 data_acquired_handler(data);
53 static char *output_fields[] = {
64 .name = "Waveman Switch Transmitter",
65 .modulation = OOK_PULSE_PWM_RAW,
69 .json_callback = &waveman_callback,
71 .demod_arg = 1, // Remove startbit
72 .fields = output_fields