UWB-Tracking
Loading...
Searching...
No Matches
watchdog.h
Go to the documentation of this file.
1#pragma once
2
9#include <freertos/FreeRTOS.h>
10#include <freertos/timers.h>
11#include <Arduino.h>
12
16class Watchdog {
17public:
22 Watchdog(unsigned long timeoutMillis)
24 {}
25
31 void resetTimer();
32
36 void begin();
37
41 void stop();
42
46 unsigned long get_timeout();
47
48private:
49 unsigned long timeoutMillis;
50 TimerHandle_t timer;
51
56 static void timerCallback(TimerHandle_t xTimer)
57 {
58 Serial.println("Watchdog fired.");
59 esp_restart();
60 }
61};
Watchdog class for monitoring and resetting a timer.
Definition: watchdog.h:16
Watchdog(unsigned long timeoutMillis)
Constructor to create a Watchdog instance.
Definition: watchdog.h:22
static void timerCallback(TimerHandle_t xTimer)
Static callback function for the timer expiration event.
Definition: watchdog.h:56
unsigned long get_timeout()
Get the milliseconds of the Timeout.
Definition: watchdog.cpp:33
unsigned long timeoutMillis
The timeout duration in milliseconds.
Definition: watchdog.h:49
TimerHandle_t timer
Timer handle for the watchdog timer.
Definition: watchdog.h:50
void stop()
Stop and release the watchdog timer.
Definition: watchdog.cpp:24
void begin()
Start the watchdog timer.
Definition: watchdog.cpp:8
void resetTimer()
Reset the timer to the initial timeout value. This has to be called within timeoutMillis or else the ...
Definition: watchdog.cpp:3