From 8fe0a53764e7cb8c52976d715f87baa04dece15f Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Mon, 22 Jan 2024 16:08:10 -0800 Subject: [PATCH] Test fix for WDT reset issue --- components/ratgdo/ratgdo.cpp | 10 ++++++++++ components/ratgdo/ratgdo.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 42b6bab..77aa95d 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -602,6 +602,16 @@ namespace ratgdo { counter.value.rolling_code_counter.value->subscribe([=](uint32_t state) { defer("rolling_code_counter", [=] { f(state); }); }); } } + + + void RATGDOComponent::defer(std::function &&f) { + App.scheduler.set_timeout(this, "", 0, [=](){ f(); App.feed_wdt();}); + } + + void RATGDOComponent::defer(const std::string &name, std::function &&f) { + App.scheduler.set_timeout(this, name, 0, [=](){ f(); App.feed_wdt();}); + } + void RATGDOComponent::subscribe_opening_duration(std::function&& f) { this->opening_duration.subscribe([=](float state) { defer("opening_duration", [=] { f(state); }); }); diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 28f34e8..faa51fb 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -166,6 +166,9 @@ namespace ratgdo { void subscribe_sync_failed(std::function&& f); void subscribe_learn_state(std::function&& f); + + void defer(std::function &&f); + void defer(const std::string &name, std::function &&f); protected: RATGDOStore isr_store_ {}; protocol::Protocol* protocol_;