Skip to content

Commit

Permalink
Polish Watchdog
Browse files Browse the repository at this point in the history
  • Loading branch information
lptr committed Dec 15, 2024
1 parent 7534848 commit 6b39669
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main/kernel/Watchdog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Watchdog {
public:
Watchdog(const String& name, const ticks timeout, bool startImmediately, WatchdogCallback callback)
: timeout(timeout)
, callback(callback) {
timer = xTimerCreate(name.c_str(), timeout.count(), false, this, [](TimerHandle_t timer) {
, callback(callback)
, timer(xTimerCreate(name.c_str(), timeout.count(), false, this, [](TimerHandle_t timer) {
LOGD("Watchdog '%s' timed out", pcTimerGetName(timer));
auto watchdog = static_cast<Watchdog*>(pvTimerGetTimerID(timer));
watchdog->callback(WatchdogState::TimedOut);
});
})) {
if (!timer) {
LOGE("Failed to create watchdog timer");
esp_system_abort("Failed to create watchdog timer");
Expand Down Expand Up @@ -60,8 +60,7 @@ class Watchdog {
private:
const ticks timeout;
const WatchdogCallback callback;

TimerHandle_t timer = nullptr;
const TimerHandle_t timer;
};

} // namespace farmhub::kernel

0 comments on commit 6b39669

Please sign in to comment.