More attempts to get lock/unlock to work
This commit is contained in:
parent
1cec8e881e
commit
15f5eab643
|
@ -106,7 +106,11 @@ 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);
|
||||
if (this->is_0x37_panel_) {
|
||||
this->request_lock_toggle_ = true;
|
||||
} else {
|
||||
this->transmit_packet(toggle_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,10 +280,21 @@ namespace secplus1 {
|
|||
this->ratgdo_->received(door_state);
|
||||
this->ratgdo_->received(ButtonState::RELEASED);
|
||||
}
|
||||
else if (cmd.type == CommandType::DOOR_STATUS_37) {
|
||||
else if (cmd.type == CommandType::DOOR_STATUS_0x37) {
|
||||
this->is_0x37_panel_ = true;
|
||||
// inject door status request
|
||||
this->sw_serial_.write(0x38);
|
||||
if (this->request_lock_toggle_) {
|
||||
this->request_lock_toggle_ = false;
|
||||
this->sw_serial_.enableIntTx(false);
|
||||
this->sw_serial_.write(toggle_lock[0]);
|
||||
ESP_LOG2(TAG, "[%d] Sent byte: [%02X]", millis(), toggle_lock[0]);
|
||||
this->sw_serial_.enableIntTx(true);
|
||||
this->scheduler_->set_timeout(this->ratgdo_, "", 3500, [=] {
|
||||
transmit_byte(toggle_lock[1], false);
|
||||
});
|
||||
} else {
|
||||
// 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);
|
||||
this->light_state = light_state;
|
||||
|
@ -308,13 +323,13 @@ namespace secplus1 {
|
|||
}
|
||||
}
|
||||
|
||||
void Secplus1::transmit_packet(const TxPacket& packet)
|
||||
void Secplus1::transmit_packet(const TxPacket& packet, bool twice, uint32_t delay)
|
||||
{
|
||||
this->print_tx_packet(packet);
|
||||
|
||||
transmit_byte(packet[0]);
|
||||
this->scheduler_->set_timeout(this->ratgdo_, "", 1500, [=] {
|
||||
transmit_byte(packet[1], true);
|
||||
this->scheduler_->set_timeout(this->ratgdo_, "", delay, [=] {
|
||||
transmit_byte(packet[1], twice);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace secplus1 {
|
|||
(TOGGLE_LIGHT_COMMIT, 0x33),
|
||||
(TOGGLE_LOCK_REQ, 0x34),
|
||||
(TOGGLE_LOCK_COMMIT, 0x35),
|
||||
(DOOR_STATUS_37, 0x37),
|
||||
(DOOR_STATUS_0x37, 0x37),
|
||||
(DOOR_STATUS, 0x38),
|
||||
(OBSTRUCTION, 0x39),
|
||||
(OTHER_STATUS, 0x3A),
|
||||
|
@ -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 twice = true, uint32_t delay = 500);
|
||||
void transmit_byte(uint32_t value, bool twice = false);
|
||||
|
||||
LightState light_state { LightState::UNKNOWN };
|
||||
|
@ -94,6 +94,7 @@ namespace secplus1 {
|
|||
WallPanelEmulationState wall_panel_emulation_state_ { WallPanelEmulationState::WAITING };
|
||||
|
||||
bool is_0x37_panel_ { false };
|
||||
bool request_lock_toggle_ { false };
|
||||
|
||||
// bool transmit_pending_ { false };
|
||||
// uint32_t transmit_pending_start_ { 0 };
|
||||
|
|
Loading…
Reference in New Issue