From ffb12e509822a1fa52541357fa35a0db1ea12761 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jun 2023 17:59:08 -0500 Subject: [PATCH] tweak --- components/ratgdo/ratgdo.cpp | 12 ++++++++++-- components/ratgdo/ratgdo_child.cpp | 1 + components/ratgdo/ratgdo_child.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 281028c..54c3609 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -257,12 +257,20 @@ namespace ratgdo { printRollingCode(); if (command != Commands::DOOR1) { // door2 is created with same counter and should always be called after door1 - ESP_LOGD(TAG, "Incrementing rolling code counter"); - this->rollingCodeCounter = (this->rollingCodeCounter + 1) & 0xfffffff; + incrementRollingCodeCounter(); } return; } + void RATGDOComponent::incrementRollingCodeCounter() + { + ESP_LOGD(TAG, "Incrementing rolling code counter"); + this->rollingCodeCounter = (this->rollingCodeCounter + 1) & 0xfffffff; + for (auto* child : this->children_) { + child->on_rolling_code_change(this->rollingCodeCounter); + } + } + void RATGDOComponent::printRollingCode() { ESP_LOGD(TAG, "Counter: %d Send code: [%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X]", diff --git a/components/ratgdo/ratgdo_child.cpp b/components/ratgdo/ratgdo_child.cpp index 850f17c..eabe097 100644 --- a/components/ratgdo/ratgdo_child.cpp +++ b/components/ratgdo/ratgdo_child.cpp @@ -11,6 +11,7 @@ namespace ratgdo { void RATGDOClient::on_lock_state(LockState state) {}; void RATGDOClient::on_motion_state(MotionState state) {}; void RATGDOClient::on_obstruction_state(ObstructionState state) {}; + void RATGDOClient::on_rolling_code_change(uint32_t rollingCodeCounter) {}; } // namespace ratgdo } // namespace esphome diff --git a/components/ratgdo/ratgdo_child.h b/components/ratgdo/ratgdo_child.h index 8b68aba..801cb6e 100644 --- a/components/ratgdo/ratgdo_child.h +++ b/components/ratgdo/ratgdo_child.h @@ -18,6 +18,7 @@ namespace ratgdo { virtual void on_lock_state(LockState state); virtual void on_motion_state(MotionState state); virtual void on_obstruction_state(ObstructionState state); + virtual void on_rolling_code_change(uint32_t rollingCodeCounter); protected: friend RATGDOComponent;