WIP
This commit is contained in:
parent
11a98edd79
commit
2730b8efeb
|
@ -97,6 +97,8 @@ namespace ratgdo {
|
||||||
{
|
{
|
||||||
auto prev_door_state = *this->door_state;
|
auto prev_door_state = *this->door_state;
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "Door state=%s", DoorState_to_string(door_state));
|
||||||
|
|
||||||
if (prev_door_state == door_state) {
|
if (prev_door_state == door_state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -183,8 +185,6 @@ namespace ratgdo {
|
||||||
|
|
||||||
this->door_state = door_state;
|
this->door_state = door_state;
|
||||||
this->door_state_received(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)
|
void RATGDOComponent::received(const LearnState learn_state)
|
||||||
|
|
|
@ -325,8 +325,7 @@ namespace secplus1 {
|
||||||
}
|
}
|
||||||
this->ratgdo_->received(door_state);
|
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;
|
this->is_0x37_panel_ = true;
|
||||||
auto cmd = this->pending_tx();
|
auto cmd = this->pending_tx();
|
||||||
if (cmd && cmd.value() == CommandType::TOGGLE_LOCK_PRESS) {
|
if (cmd && cmd.value() == CommandType::TOGGLE_LOCK_PRESS) {
|
||||||
|
@ -355,12 +354,10 @@ namespace secplus1 {
|
||||||
this->lock_state = lock_state;
|
this->lock_state = lock_state;
|
||||||
this->ratgdo_->received(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;
|
ObstructionState obstruction_state = cmd.resp == 0 ? ObstructionState::CLEAR : ObstructionState::OBSTRUCTED;
|
||||||
this->ratgdo_->received(obstruction_state);
|
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) {
|
if (cmd.resp == 0x31) {
|
||||||
this->wall_panel_starting_ = true;
|
this->wall_panel_starting_ = true;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +374,6 @@ namespace secplus1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Secplus1::do_transmit_if_pending()
|
bool Secplus1::do_transmit_if_pending()
|
||||||
{
|
{
|
||||||
auto cmd = this->pop_pending_tx();
|
auto cmd = this->pop_pending_tx();
|
||||||
|
@ -420,7 +416,6 @@ namespace secplus1 {
|
||||||
return cmd.request;
|
return cmd.request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
optional<CommandType> Secplus1::pop_pending_tx()
|
optional<CommandType> Secplus1::pop_pending_tx()
|
||||||
{
|
{
|
||||||
auto cmd = this->pending_tx();
|
auto cmd = this->pending_tx();
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace secplus2 {
|
||||||
if (action == LockAction::UNKNOWN) {
|
if (action == LockAction::UNKNOWN) {
|
||||||
return;
|
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)
|
void Secplus2::door_action(DoorAction action)
|
||||||
|
@ -145,9 +145,9 @@ namespace secplus2 {
|
||||||
{
|
{
|
||||||
using Tag = Args::Tag;
|
using Tag = Args::Tag;
|
||||||
if (args.tag == Tag::query_status) {
|
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) {
|
} 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) {
|
} else if (args.tag == Tag::get_rolling_code_counter) {
|
||||||
return Result(RollingCodeCounter{std::addressof(this->rolling_code_counter_)});
|
return Result(RollingCodeCounter{std::addressof(this->rolling_code_counter_)});
|
||||||
} else if (args.tag == Tag::set_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)
|
void Secplus2::handle_command(const Command& cmd)
|
||||||
{
|
{
|
||||||
|
ESP_LOG1(TAG, "Handle command: %s", CommandType_to_string(cmd.type));
|
||||||
|
|
||||||
if (cmd.type == CommandType::STATUS) {
|
if (cmd.type == CommandType::STATUS) {
|
||||||
|
|
||||||
this->ratgdo_->received(to_DoorState(cmd.nibble, DoorState::UNKNOWN));
|
this->ratgdo_->received(to_DoorState(cmd.nibble, DoorState::UNKNOWN));
|
||||||
this->ratgdo_->received(to_LightState((cmd.byte2 >> 1) & 1, LightState::UNKNOWN));
|
this->ratgdo_->received(to_LightState((cmd.byte2 >> 1) & 1, LightState::UNKNOWN));
|
||||||
this->ratgdo_->received(to_LockState((cmd.byte2 & 1), LockState::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)
|
void Secplus2::send_command(Command command, bool increment)
|
||||||
|
|
Loading…
Reference in New Issue