Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TR-502MSV remote controller for RC-710 smart sockets #2921

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rtl_433_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
DECL(mueller_hotrod) \
DECL(thermopro_tp28b) \
DECL(tpms_bmwg3) \
DECL(tr_502msv) \

/* Add new decoders here. */

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ add_library(r_433 STATIC
devices/tpms_toyota.c
devices/tpms_truck.c
devices/tpms_tyreguard400.c
devices/tr_502msv.c
devices/ts_ft002.c
devices/ttx201.c
devices/vaillant_vrt340f.c
Expand Down
91 changes: 91 additions & 0 deletions src/devices/tr_502msv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/** @file
TR-502MSV remote controller for RC-710DX.

Copyright (C) 2024 Filip Kosecek <filip.kosecek@gmail.com>

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 "decoder.h"

/**
TR-502MSV remote controller for RC-710DX.

21-bit data packet format, repeated up to 4 times
PIIIIIII IIIIISSS OCRUU

- P: 1-bit preamble
- I: 12-bit device id
- S: 3-bit socket id
- O: 1-bit on/off
- C: 1-bit command - brightness/switch
- R: 1 reserved bit (always 0)
- U: 2 unknown bits, most likely a checksum

*/

static int tr502msv_decode(r_device *decoder, bitbuffer_t *buffer)
{
int device_id;
data_t *output_data;
uint8_t socket_id;
uint8_t *b;
const char *command_str, *socket_str;
const char *sockets[] = {"1", "3", "2", "4", "ALL"};
const char *commands[] = {"OFF", "BRIGHT", "ON", "DIM"};

if (buffer->num_rows != 1 || buffer->bits_per_row[0] != 21)
return DECODE_ABORT_LENGTH;

b = buffer->bb[0];
if ((b[0] & (1 << 7)) == 0)
return DECODE_ABORT_EARLY;
if ((b[2] & (1 << 5)) != 0)
return DECODE_FAIL_SANITY;

device_id = ((b[0] & 0x7f) << 5) | (b[1] >> 3);
command_str = commands[b[2] >> 6];
socket_id = b[1] & 0x7;
if (socket_id % 2 == 0)
socket_str = sockets[socket_id >> 1];
else if (socket_id == 0x7)
socket_str = sockets[4];
else
return DECODE_FAIL_SANITY;

/* clang-format off */
output_data = data_make (
"model", "Model", DATA_STRING, "TR-502MSV",
"id", "Device ID", DATA_FORMAT, "%u", DATA_INT, device_id,
"socket_id", "Socket", DATA_STRING, socket_str,
"command", "Command", DATA_STRING, command_str,
NULL
);
/* clang-format on */
decoder_output_data(decoder, output_data);

return 1;
}

static const char *output_fields[] = {
"model",
"id",
"device_id",
"socket_id",
"command",
NULL,
};

const r_device tr_502msv = {
.name = "TR-502MSV remote smart socket controller",
.modulation = OOK_PULSE_PWM,
.short_width = 740,
.long_width = 1400,
.tolerance = 70,
.reset_limit = 84000,
.decode_fn = tr502msv_decode,
.fields = output_fields,
};