Acurite 5in1 minor fixes
[rtl-433.git] / src / devices / leak.c
1 #include "rtl_433.h"
2
3 int leak_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS], int16_t bits_per_row[BITBUF_ROWS]) {
4     int i,j,k;
5     int rows_used[BITBUF_ROWS];
6     int col_max = 0;
7     int row_cnt = 0;
8
9     // determine what part of bb[][] has non-zero data to avoid
10     // outputting lots of empty rows 
11     for (i=0 ; i<BITBUF_ROWS ; i++) {
12         for (j=BITBUF_COLS - 1 ; j > 0 ; j--) {
13             if (bb[i][j] != 0)
14                 break;
15         }
16         if (j != 0) {
17             rows_used[i] = 1;
18             row_cnt++;
19             if (j > col_max)
20                 col_max = j;
21         } else {
22             rows_used[i] = 0;
23         }
24     }
25
26     if (row_cnt != 1) {
27         return 0;
28     }
29
30     if (col_max !=3) {
31         return 0;
32     }
33
34     if ((bb[0][0] == 0x76) || (bb[0][0] == 0x77)) {
35
36         fprintf(stdout,"ALARM:TYPE=LEAK,ID=%2X%2X%2X%2X\n",bb[0][0],bb[0][1],bb[0][2],bb[0][3]);
37
38     }
39
40     return 1;
41
42 }
43
44 r_device leak = {
45     /* .id             = */ 20,
46     /* .name           = */ "Leak sensor",
47     /* .modulation     = */ OOK_MANCHESTER,
48     /* .short_limit    = */ 150,
49     /* .long_limit     = */ 0, 
50     /* .reset_limit    = */ 1000,
51     /* .json_callback  = */ &leak_callback,
52 };