This commit is contained in:
Marius Muja 2024-01-15 20:55:52 -08:00
parent 11a98edd79
commit 2730b8efeb
3 changed files with 14 additions and 15 deletions

View File

@ -97,6 +97,8 @@ namespace ratgdo {
{
auto prev_door_state = *this->door_state;
ESP_LOGD(TAG, "Door state=%s", DoorState_to_string(door_state));
if (prev_door_state == door_state) {
return;
}
@ -183,8 +185,6 @@ namespace ratgdo {
this->door_state = door_state;
this->door_state_received(door_state);
ESP_LOGD(TAG, "Door state=%s", DoorState_to_string(door_state));
}
void RATGDOComponent::received(const LearnState learn_state)

View File

@ -32,10 +32,10 @@ namespace secplus1 {
auto tx_cmd = this->pending_tx();
if (
(millis() - this->last_tx_) > 200 && // don't send twice in a period
(millis() - this->last_rx_) > 50 && // time to send it
(millis() - this->last_rx_) > 50 && // time to send it
tx_cmd && // have pending command
!(this->is_0x37_panel_ && tx_cmd.value() == CommandType::TOGGLE_LOCK_PRESS) &&
this->wall_panel_emulation_state_ != WallPanelEmulationState::RUNNING
this->wall_panel_emulation_state_ != WallPanelEmulationState::RUNNING
) {
this->do_transmit_if_pending();
}
@ -325,8 +325,7 @@ namespace secplus1 {
}
this->ratgdo_->received(door_state);
}
}
else if (cmd.req == CommandType::QUERY_DOOR_STATUS_0x37) {
} else if (cmd.req == CommandType::QUERY_DOOR_STATUS_0x37) {
this->is_0x37_panel_ = true;
auto cmd = this->pending_tx();
if (cmd && cmd.value() == CommandType::TOGGLE_LOCK_PRESS) {
@ -355,12 +354,10 @@ namespace secplus1 {
this->lock_state = lock_state;
this->ratgdo_->received(lock_state);
}
}
else if (cmd.req == CommandType::OBSTRUCTION) {
} else if (cmd.req == CommandType::OBSTRUCTION) {
ObstructionState obstruction_state = cmd.resp == 0 ? ObstructionState::CLEAR : ObstructionState::OBSTRUCTED;
this->ratgdo_->received(obstruction_state);
}
else if (cmd.req == CommandType::TOGGLE_DOOR_RELEASE) {
} else if (cmd.req == CommandType::TOGGLE_DOOR_RELEASE) {
if (cmd.resp == 0x31) {
this->wall_panel_starting_ = true;
}
@ -377,7 +374,6 @@ namespace secplus1 {
}
}
bool Secplus1::do_transmit_if_pending()
{
auto cmd = this->pop_pending_tx();
@ -420,7 +416,6 @@ namespace secplus1 {
return cmd.request;
}
optional<CommandType> Secplus1::pop_pending_tx()
{
auto cmd = this->pending_tx();

View File

@ -129,7 +129,7 @@ namespace secplus2 {
if (action == LockAction::UNKNOWN) {
return;
}
this->send_command(Command(CommandType::LOCK, static_cast<uint8_t>(action)));
// this->send_command(Command(CommandType::LOCK, static_cast<uint8_t>(action)));
}
void Secplus2::door_action(DoorAction action)
@ -145,9 +145,9 @@ namespace secplus2 {
{
using Tag = Args::Tag;
if (args.tag == Tag::query_status) {
this->send_command(CommandType::GET_STATUS);
this->send_command(Command{CommandType::GET_STATUS});
} else if (args.tag == Tag::query_openings) {
this->send_command(CommandType::GET_OPENINGS);
this->send_command(Command{CommandType::GET_OPENINGS});
} else if (args.tag == Tag::get_rolling_code_counter) {
return Result(RollingCodeCounter{std::addressof(this->rolling_code_counter_)});
} else if (args.tag == Tag::set_rolling_code_counter) {
@ -359,7 +359,10 @@ namespace secplus2 {
void Secplus2::handle_command(const Command& cmd)
{
ESP_LOG1(TAG, "Handle command: %s", CommandType_to_string(cmd.type));
if (cmd.type == CommandType::STATUS) {
this->ratgdo_->received(to_DoorState(cmd.nibble, DoorState::UNKNOWN));
this->ratgdo_->received(to_LightState((cmd.byte2 >> 1) & 1, LightState::UNKNOWN));
this->ratgdo_->received(to_LockState((cmd.byte2 & 1), LockState::UNKNOWN));
@ -425,6 +428,7 @@ namespace secplus2 {
}
}
ESP_LOG1(TAG, "Done handle command: %s", CommandType_to_string(cmd.type));
}
void Secplus2::send_command(Command command, bool increment)