From be4d6669673b7d2c74b07cf1927e95b60af996fd Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Fri, 12 Jan 2024 08:51:56 -0800 Subject: [PATCH] Inject 0x38 after 0x37 to try to fix door status issue on some wall panels --- components/ratgdo/secplus1.cpp | 16 ++++++++++++++-- components/ratgdo/secplus1.h | 10 ++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/ratgdo/secplus1.cpp b/components/ratgdo/secplus1.cpp index f4daf28..0a3acb1 100644 --- a/components/ratgdo/secplus1.cpp +++ b/components/ratgdo/secplus1.cpp @@ -180,6 +180,15 @@ namespace secplus1 { } rx_packet[byte_count++] = ser_byte; reading_msg = true; + + if (ser_byte == 0x37) { + rx_packet[byte_count++] = 0; + reading_msg = false; + byte_count = 0; + ESP_LOG2(TAG, "[%d] Received command: [%02X]", millis(), rx_packet[0]); + return this->decode_packet(rx_packet); + } + break; } } @@ -262,7 +271,10 @@ namespace secplus1 { this->ratgdo_->received(door_state); } } - else if (cmd.type == CommandType::OTHER_STATUS) { + else if (cmd.type == CommandType::DOOR_STATUS_37) { + // inject door status request + this->sw_serial_.write(0x38); + } else if (cmd.type == CommandType::OTHER_STATUS) { LightState light_state = to_LightState((cmd.value >> 2) & 1, LightState::UNKNOWN); if (this->light_state != light_state) { this->light_state = light_state; @@ -281,7 +293,7 @@ namespace secplus1 { ObstructionState obstruction_state = cmd.value == 0 ? ObstructionState::CLEAR : ObstructionState::OBSTRUCTED; this->ratgdo_->received(obstruction_state); } - else if (cmd.type == CommandType::WALL_PANEL_STARTING) { + else if (cmd.type == CommandType::TOGGLE_DOOR_COMMIT) { if (cmd.value == 0x31) { this->wall_panel_starting_ = true; } diff --git a/components/ratgdo/secplus1.h b/components/ratgdo/secplus1.h index bef405b..db45796 100644 --- a/components/ratgdo/secplus1.h +++ b/components/ratgdo/secplus1.h @@ -31,9 +31,15 @@ namespace secplus1 { static const uint8_t secplus1_states[] = {0x35,0x35,0x35,0x35,0x33,0x33,0x53,0x53,0x38,0x3A,0x3A,0x3A,0x39,0x38,0x3A, 0x38,0x3A,0x39,0x3A}; ENUM(CommandType, uint16_t, - (WALL_PANEL_STARTING, 0x31), + (TOGGLE_DOOR_REQ, 0x30), + (TOGGLE_DOOR_COMMIT, 0x31), + (TOGGLE_LIGHT_REQ, 0x32), + (TOGGLE_LIGHT_COMMIT, 0x33), + (TOGGLE_LOCK_REQ, 0x34), + (TOGGLE_LOCK_COMMIT, 0x35), + (DOOR_STATUS_37, 0x37), (DOOR_STATUS, 0x38), - (OBSTRUCTION, 0x39), // + (OBSTRUCTION, 0x39), (OTHER_STATUS, 0x3A), (UNKNOWN, 0xFF), )