1 /* Chuango Security Technology Corporation
4 * G5 GSM/SMS/RFID Touch Alarm System (Alarm, Disarm, ...)
5 * DWC-100 Door sensor (Default: Normal Zone)
6 * DWC-102 Door sensor (Default: Normal Zone)
7 * KP-700 Wireless Keypad (Arm, Disarm, Home Mode, Alarm!)
8 * PIR-900 PIR sensor (Default: Home Mode Zone)
9 * RC-80 Remote Control (Arm, Disarm, Home Mode, Alarm!)
10 * SMK-500 Smoke sensor (Default: 24H Zone)
11 * WI-200 Water sensor (Default: 24H Zone)
13 * Copyright (C) 2015 Tommy Vestermark
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
20 #include "pulse_demod.h"
25 static int chuango_callback(bitbuffer_t *bitbuffer) {
26 bitrow_t *bb = bitbuffer->bb;
32 unsigned bits = bitbuffer->bits_per_row[0];
36 && (b[3] & 0x80) // Last bit (MSB here) is always 1
37 && (b[0] || b[1] || (b[2] & 0xF0)) // Reduce false positives. ID 0x00000 not supported
39 uint32_t ID = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4); // ID is 20 bits (Ad: "1 Million combinations" :-)
41 uint32_t CMD_ID = b[2] & 0x0F;
43 char time_str[LOCAL_TIME_BUFLEN];
46 case 0xF: CMD = "?"; break;
47 case 0xE: CMD = "?"; break;
48 case 0xD: CMD = "Low Battery"; break;
49 case 0xC: CMD = "?"; break;
50 case 0xB: CMD = "24H Zone"; break;
51 case 0xA: CMD = "Single Delay Zone"; break;
52 case 0x9: CMD = "?"; break;
53 case 0x8: CMD = "Arm"; break;
54 case 0x7: CMD = "Normal Zone"; break;
55 case 0x6: CMD = "Home Mode Zone"; break;
56 case 0x5: CMD = "?"; break;
57 case 0x4: CMD = "Home Mode"; break;
58 case 0x3: CMD = "Tamper"; break;
59 case 0x2: CMD = "Alarm"; break;
60 case 0x1: CMD = "Disarm"; break;
61 case 0x0: CMD = "Test"; break;
62 default: CMD = ""; break;
64 local_time_str(0, time_str);
65 data = data_make("time", "", DATA_STRING, time_str,
66 "model", "", DATA_STRING, "Chuango Security Technology",
67 "id", "ID", DATA_INT, ID,
68 "cmd", "CMD", DATA_STRING, CMD,
69 "cmd_id", "CMD_ID", DATA_INT, CMD_ID,
72 data_acquired_handler(data);
78 static char *output_fields[] = {
87 PWM_Precise_Parameters pwm_precise_parameters = {
88 .pulse_tolerance = 40,
89 .pulse_sync_width = 0, // No sync bit used
93 .name = "Chuango Security Technology",
94 .modulation = OOK_PULSE_PWM_PRECISE,
95 .short_limit = 568, // Pulse: Short 568µs, Long 1704µs
96 .long_limit = 1704, // Gaps: Short 568µs, Long 1696µs
97 .reset_limit = 1800, // Intermessage Gap 17200µs (individually for now)
98 .json_callback = &chuango_callback,
100 .demod_arg = (uintptr_t)&pwm_precise_parameters,