diff --git a/components/ratgdo/secplus1.cpp b/components/ratgdo/secplus1.cpp index b175981..cc0b666 100644 --- a/components/ratgdo/secplus1.cpp +++ b/components/ratgdo/secplus1.cpp @@ -106,7 +106,7 @@ namespace secplus1 { if (action == LockAction::TOGGLE || (action == LockAction::LOCK && this->lock_state == LockState::UNLOCKED) || (action == LockAction::UNLOCK && this->lock_state == LockState::LOCKED)) { - this->transmit_packet(toggle_lock); + this->transmit_packet(toggle_lock, this->is_0x37_panel_); } } @@ -236,6 +236,12 @@ namespace secplus1 { return Command{cmd_type, packet[1]}; } + // unknown meaning of observed command-responses: + // 40 00 and 40 80 + // 53 01 + // C0 3F + // F8 3F + // FE 3F void Secplus1::handle_command(const Command& cmd) { @@ -268,6 +274,7 @@ namespace secplus1 { this->ratgdo_->received(door_state); } else if (cmd.type == CommandType::DOOR_STATUS_37) { + this->is_0x37_panel_ = true; // inject door status request this->sw_serial_.write(0x38); } else if (cmd.type == CommandType::OTHER_STATUS) { @@ -296,7 +303,7 @@ namespace secplus1 { } } - void Secplus1::transmit_packet(const TxPacket& packet) + void Secplus1::transmit_packet(const TxPacket& packet, bool first_byte) { this->print_tx_packet(packet); @@ -310,18 +317,19 @@ namespace secplus1 { this->sw_serial_.write(packet[0]); this->sw_serial_.enableIntTx(true); }); - this->scheduler_->set_timeout(this->ratgdo_, "", tx_delay+250, [=] { - this->sw_serial_.enableIntTx(false); - this->sw_serial_.write(packet[1]); - this->sw_serial_.enableIntTx(true); - }); - this->scheduler_->set_timeout(this->ratgdo_, "", tx_delay+290, [=] { - this->sw_serial_.enableIntTx(false); - this->sw_serial_.write(packet[1]); - this->sw_serial_.enableIntTx(true); - }); - + if (!first_byte) { + this->scheduler_->set_timeout(this->ratgdo_, "", tx_delay+250, [=] { + this->sw_serial_.enableIntTx(false); + this->sw_serial_.write(packet[1]); + this->sw_serial_.enableIntTx(true); + }); + this->scheduler_->set_timeout(this->ratgdo_, "", tx_delay+290, [=] { + this->sw_serial_.enableIntTx(false); + this->sw_serial_.write(packet[1]); + this->sw_serial_.enableIntTx(true); + }); + } } } // namespace secplus1 diff --git a/components/ratgdo/secplus1.h b/components/ratgdo/secplus1.h index db45796..2070097 100644 --- a/components/ratgdo/secplus1.h +++ b/components/ratgdo/secplus1.h @@ -81,7 +81,7 @@ namespace secplus1 { void print_tx_packet(const TxPacket& packet) const; optional decode_packet(const RxPacket& packet) const; - void transmit_packet(const TxPacket& packet); + void transmit_packet(const TxPacket& packet, bool first_byte = false); LightState light_state { LightState::UNKNOWN }; LockState lock_state { LockState::UNKNOWN }; @@ -92,6 +92,8 @@ namespace secplus1 { uint32_t wall_panel_emulation_start_ { 0 }; WallPanelEmulationState wall_panel_emulation_state_ { WallPanelEmulationState::WAITING }; + bool is_0x37_panel_ { false }; + // bool transmit_pending_ { false }; // uint32_t transmit_pending_start_ { 0 }; TxPacket tx_packet_;