Add support for Kerui WD51 Water leak sensor (closes #1406)
This commit is contained in:
parent
0da03c3903
commit
1e49e5058f
1 changed files with 34 additions and 29 deletions
|
@ -1,14 +1,16 @@
|
|||
/* Kerui PIR / Contact Sensor
|
||||
*
|
||||
* Such as
|
||||
* http://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=p2050601.m570.l1313.TR0.TRC0.H0.Xkerui+pir.TRS0&_nkw=kerui+pir&_sacat=0
|
||||
*
|
||||
* also tested with:
|
||||
* KERUI D026 Window Door Magnet Sensor Detector (433MHz) https://fccid.io/2AGNGKR-D026
|
||||
* events: open / close / tamper / battery low (below 5V of 12V battery)
|
||||
*
|
||||
* Note: simple 24 bit fixed ID protocol (x1527 style) and should be handled by the flex decoder.
|
||||
*/
|
||||
/**
|
||||
Kerui PIR / Contact Sensor.
|
||||
|
||||
Such as
|
||||
http://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=p2050601.m570.l1313.TR0.TRC0.H0.Xkerui+pir.TRS0&_nkw=kerui+pir&_sacat=0
|
||||
|
||||
also tested with:
|
||||
KERUI D026 Window Door Magnet Sensor Detector (433MHz) https://fccid.io/2AGNGKR-D026
|
||||
events: open / close / tamper / battery low (below 5V of 12V battery)
|
||||
|
||||
Note: simple 24 bit fixed ID protocol (x1527 style) and should be handled by the flex decoder.
|
||||
There is a leading sync bit with a wide gap which runs into the preceeding packet, it's ignored as 25th data bit.
|
||||
*/
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
|
@ -19,9 +21,13 @@ static int kerui_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
|
|||
int cmd;
|
||||
char *cmd_str;
|
||||
|
||||
if (bitbuffer->bits_per_row[0] != 25)
|
||||
int r = bitbuffer_find_repeated_row(bitbuffer, 9, 25); // expected are 25 packets, require 9
|
||||
if (r < 0)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
b = bitbuffer->bb[0];
|
||||
|
||||
if (bitbuffer->bits_per_row[r] != 25)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
b = bitbuffer->bb[r];
|
||||
|
||||
//invert bits, short pulse is 0, long pulse is 1
|
||||
b[0] = ~b[0];
|
||||
|
@ -35,6 +41,7 @@ static int kerui_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
|
|||
case 0xe: cmd_str = "open"; break;
|
||||
case 0x7: cmd_str = "close"; break;
|
||||
case 0xb: cmd_str = "tamper"; break;
|
||||
case 0x5: cmd_str = "water"; break;
|
||||
case 0xf: cmd_str = "battery"; break;
|
||||
default: cmd_str = NULL; break;
|
||||
}
|
||||
|
@ -54,23 +61,21 @@ static int kerui_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
|
|||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
"model",
|
||||
"id",
|
||||
"cmd",
|
||||
"state",
|
||||
NULL
|
||||
"model",
|
||||
"id",
|
||||
"cmd",
|
||||
"state",
|
||||
NULL,
|
||||
};
|
||||
|
||||
r_device kerui = {
|
||||
.name = "Kerui PIR / Contact Sensor",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 320,
|
||||
.long_width = 960,
|
||||
.reset_limit = 1100, // 9900,
|
||||
//.gap_limit = 1100,
|
||||
.sync_width = 480,
|
||||
.tolerance = 80, // us
|
||||
.decode_fn = &kerui_callback,
|
||||
.disabled = 0,
|
||||
.fields = output_fields,
|
||||
.name = "Kerui PIR / Contact Sensor",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 400,
|
||||
.long_width = 960,
|
||||
.gap_limit = 1100,
|
||||
.reset_limit = 9900,
|
||||
.tolerance = 160,
|
||||
.decode_fn = &kerui_callback,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue