- Merged with upstream version
[rtl-433.git] / src / devices / waveman.c~
1 #include "rtl_433.h"
2
3 static int waveman_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS],int16_t bits_per_row[BITBUF_ROWS]) {
4     /* Two bits map to 2 states, 0 1 -> 0 and 1 1 -> 1 */
5     int i;
6     uint8_t nb[3] = {0};
7
8     if (((bb[0][0]&0x55)==0x55) && ((bb[0][1]&0x55)==0x55) && ((bb[0][2]&0x55)==0x55) && ((bb[0][3]&0x55)==0x00)) {
9         for (i=0 ; i<3 ; i++) {
10             nb[i] |= ((bb[0][i]&0xC0)==0xC0) ? 0x00 : 0x01;
11             nb[i] |= ((bb[0][i]&0x30)==0x30) ? 0x00 : 0x02;
12             nb[i] |= ((bb[0][i]&0x0C)==0x0C) ? 0x00 : 0x04;
13             nb[i] |= ((bb[0][i]&0x03)==0x03) ? 0x00 : 0x08;
14         }
15
16         fprintf(stderr, "Remote button event:\n");
17         fprintf(stderr, "model   = Waveman Switch Transmitter, %d bits\n",bits_per_row[1]);
18         fprintf(stderr, "id      = %c\n", 'A'+nb[0]);
19         fprintf(stderr, "channel = %d\n", (nb[1]>>2)+1);
20         fprintf(stderr, "button  = %d\n", (nb[1]&3)+1);
21         fprintf(stderr, "state   = %s\n", (nb[2]==0xe) ? "on" : "off");
22         fprintf(stderr, "%02x %02x %02x\n",nb[0],nb[1],nb[2]);
23
24         if (debug_output)
25             debug_callback(bb, bits_per_row);
26
27         return 1;
28     }
29     return 0;
30 }
31
32 r_device waveman = {
33     /* .id             = */ 6,
34     /* .name           = */ "Waveman Switch Transmitter",
35     /* .modulation     = */ OOK_PWM_P,
36     /* .short_limit    = */ 1000/4,
37     /* .long_limit     = */ 8000/4,
38     /* .reset_limit    = */ 30000/4,
39     /* .json_callback  = */ &waveman_callback,
40 };