Attempt to fix lock action for 398LM wall panel

This commit is contained in:
Marius Muja 2024-01-12 14:10:35 -08:00
parent ba19d80867
commit a6fe612525
2 changed files with 24 additions and 14 deletions

View File

@ -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,6 +317,8 @@ namespace secplus1 {
this->sw_serial_.write(packet[0]);
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]);
@ -320,8 +329,7 @@ namespace secplus1 {
this->sw_serial_.write(packet[1]);
this->sw_serial_.enableIntTx(true);
});
}
}
} // namespace secplus1

View File

@ -81,7 +81,7 @@ namespace secplus1 {
void print_tx_packet(const TxPacket& packet) const;
optional<Command> 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_;