3 * Code derrived from akhan_100F14.c
6 * 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
10 #include "pulse_demod.h"
14 static int kerui_callback(bitbuffer_t *bitbuffer) {
18 char time_str[LOCAL_TIME_BUFLEN];
24 bitrow_t *bb = bitbuffer->bb;
26 for (int i=0; i<bitbuffer->num_rows; i++) {
29 //invert bits, short pulse is 0, long pulse is 1
34 unsigned bits = bitbuffer->bits_per_row[i];
37 local_time_str(0, time_str);
39 ID = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4);
40 dataBits = b[2] & 0x0F;
58 if (isKerui == 1) break;
63 data = data_make( "time", "", DATA_STRING, time_str,
64 "device", "", DATA_STRING, "Kerui Sensor",
65 "id", "ID (20bit)", DATA_FORMAT, "0x%x", DATA_INT, ID,
66 "data", "Data (4bit)", DATA_STRING, CMD,
68 data_acquired_handler(data);
75 static char *output_fields[] = {
84 PWM_Precise_Parameters pwm_precise_parameters_kerui = {
85 .pulse_tolerance = 20,
86 .pulse_sync_width = 0,
90 .name = "Kerui Sensor",
91 .modulation = OOK_PULSE_PWM_RAW,
95 .json_callback = &kerui_callback,
97 .demod_arg = (uintptr_t)&pwm_precise_parameters_kerui,