1 /* Generic remotes and sensors using PT2260/PT2262 SC2260/SC2262 EV1527 protocol
7 * Copyright (C) 2015 Tommy Vestermark
8 * Copyright (C) 2015 nebman
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "pulse_demod.h"
19 static int generic_remote_callback(bitbuffer_t *bitbuffer) {
20 bitrow_t *bb = bitbuffer->bb;
23 char time_str[LOCAL_TIME_BUFLEN];
27 //invert bits, short pulse is 0, long pulse is 1
32 unsigned bits = bitbuffer->bits_per_row[0];
36 && (b[3] & 0x80) // Last bit (MSB here) is always 1
37 && (b[0] || b[1]) // Reduce false positives. ID 0x0000 not supported
38 && (b[2]) // Reduce false positives. CMD 0x00 not supported
41 uint32_t ID_16b = b[0] << 8 | b[1];
42 unsigned char CMD_8b = b[2];
44 // fprintf(stdout, "Generic remote keypress / sensor\n");
45 // fprintf(stdout, "ID 16bit = 0x%04X\n", ID_16b);
46 // fprintf(stdout, "CMD 8bit = 0x%02X\n", CMD_8b);
49 // output tristate coding
51 uint32_t FULL = b[0] << 16 | b[1] << 8 | b[2];
54 // fprintf(stdout, "TRISTATE = ");
55 for (signed char i=22; i>=0; i-=2) {
57 switch ((FULL>>i) & 0x03) {
58 case 0x00: c = '0'; break;
59 case 0x01: c = 'F'; break;
60 case 0x02: c = '!'; break; // tristate 10 is invalid code for SC226x but valid in EV1527
61 case 0x03: c = '1'; break;
62 default: c = '?'; break; // not possible anyway
70 // fprintf(stdout, "\n");
71 local_time_str(0, time_str);
73 // fprintf(stdout, "ID 16bit = 0x%04X\n", ID_16b);
74 // fprintf(stdout, "CMD 8bit = 0x%02X\n", CMD_8b);
77 "time", "", DATA_STRING, time_str,
78 "model", "", DATA_STRING, "Generic Remote",
79 "id", "House Code", DATA_INT, ID_16b,
80 "cmd", "Command", DATA_INT, CMD_8b,
81 "tristate", "Tri-State", DATA_STRING, tristate,
84 data_acquired_handler(data);
93 PWM_Precise_Parameters pwm_precise_parameters_generic = {
94 .pulse_tolerance = 50,
95 .pulse_sync_width = 0, // No sync bit used
98 r_device generic_remote = {
99 .name = "Generic Remote SC226x EV1527",
100 .modulation = OOK_PULSE_PWM_PRECISE,
104 .json_callback = &generic_remote_callback,
106 .demod_arg = (uintptr_t)&pwm_precise_parameters_generic,