Редизайн на основе текущей ветки мейнстрима + новые устройства.
[rtl-433.git] / src / devices / lelux.c
diff --git a/src/devices/lelux.c b/src/devices/lelux.c
new file mode 100644 (file)
index 0000000..201c3d6
--- /dev/null
@@ -0,0 +1,63 @@
+/* Lelux alarm sensors
+ *
+ * Tested devices:
+ * 616PR
+ * EV1527
+ *
+ * Copyright (C) 2015 Tommy Vestermark
+ * Copyright (C) 2015 nebman
+ * COpyringt (C) 2016 Roman Bazalevskiy
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include "rtl_433.h"
+#include "pulse_demod.h"
+#include "data.h"
+#include "util.h"
+
+static int lelux_callback(bitbuffer_t *bitbuffer) {
+       bitrow_t *bb = bitbuffer->bb;
+       uint8_t *b = bb[0];
+       data_t *data;
+       char time_str[LOCAL_TIME_BUFLEN];
+
+       if (bitbuffer->num_rows != 1) return 0;
+
+       unsigned bits = bitbuffer->bits_per_row[0];
+
+       // Validate package
+       if (bits == 32) {
+
+               uint32_t FULL = b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
+               char id_buf[16];
+               snprintf(id_buf,15,"%08x",FULL);
+
+               local_time_str(0, time_str);
+
+               data = data_make(
+                       "time",         "",             DATA_STRING, time_str,
+                       "model",        "",             DATA_STRING, "Lelux PIR",
+                       "id",           "House Code",   DATA_STRING, id_buf,
+                       "command",      "",             DATA_STRING, "PIR",
+                      NULL);
+
+               data_acquired_handler(data);
+
+               return 1;
+       }
+       return 0;
+}
+
+
+r_device lelux = {
+       .name           = "Lelux PIR sensor",
+        .modulation    = OOK_PULSE_PPM_RAW,
+        .short_limit   = 1000,
+        .long_limit    = 1600,
+        .reset_limit   = 4000,
+       .json_callback  = &lelux_callback,
+       .disabled       = 0,
+       .demod_arg      = 0
+};