X-Git-Url: https://git.rvb.name/rtl-433.git/blobdiff_plain/7771049ddd733b759484442a3b10ade8faea75ff..337eb4ba945097205fbb6a3ca7912fb0697092d1:/src/devices/leak.c diff --git a/src/devices/leak.c b/src/devices/leak.c new file mode 100644 index 0000000..e656be0 --- /dev/null +++ b/src/devices/leak.c @@ -0,0 +1,52 @@ +#include "rtl_433.h" + +int leak_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS], int16_t bits_per_row[BITBUF_ROWS]) { + int i,j,k; + int rows_used[BITBUF_ROWS]; + int col_max = 0; + int row_cnt = 0; + + // determine what part of bb[][] has non-zero data to avoid + // outputting lots of empty rows + for (i=0 ; i 0 ; j--) { + if (bb[i][j] != 0) + break; + } + if (j != 0) { + rows_used[i] = 1; + row_cnt++; + if (j > col_max) + col_max = j; + } else { + rows_used[i] = 0; + } + } + + if (row_cnt != 1) { + return 0; + } + + if (col_max !=3) { + return 0; + } + + if ((bb[0][0] == 0x76) || (bb[0][0] == 0x77)) { + + fprintf(stdout,"ALARM:TYPE=LEAK,ID=%2X%2X%2X%2X\n",bb[0][0],bb[0][1],bb[0][2],bb[0][3]); + + } + + return 1; + +} + +r_device leak = { + /* .id = */ 20, + /* .name = */ "Leak sensor", + /* .modulation = */ OOK_MANCHESTER, + /* .short_limit = */ 150, + /* .long_limit = */ 0, + /* .reset_limit = */ 1000, + /* .json_callback = */ &leak_callback, +};