|
SensESP 3.6.1-alpha
Universal Signal K sensor toolkit ESP32
|
Restart the device after a prolonged network outage. More...
#include <sensesp/system/wifi_watchdog.h>
Public Member Functions | |
| WiFiWatchdog (std::shared_ptr< ValueProducer< NetworkState > > network_state, int timeout_s, const String &config_path="/System/WiFi Watchdog") | |
| virtual | ~WiFiWatchdog () |
| virtual bool | to_json (JsonObject &root) override |
| virtual bool | from_json (const JsonObject &config) override |
Public Member Functions inherited from sensesp::FileSystemSaveable | |
| FileSystemSaveable (const String &config_path) | |
| virtual bool | load () override |
| Load and populate the object from a persistent storage. | |
| virtual bool | save () override |
| Save the object to a persistent storage. | |
| virtual bool | clear () override |
| Delete the data from a persistent storage. | |
| bool | find_config_file (const String &config_path, String &filename) |
Public Member Functions inherited from sensesp::Saveable | |
| Saveable (const String &config_path) | |
| virtual bool | refresh () |
| Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state. | |
| const String & | get_config_path () const |
Static Public Member Functions | |
| static bool | is_valid_timeout_s (int timeout_s) |
Static Public Attributes | |
| static constexpr int | kMaxTimeoutS = 7 * 24 * 3600 |
Protected Member Functions | |
| void | on_network_state (NetworkState state) |
| void | poll () |
| uint32_t | timeout_ms () const |
Protected Attributes | |
| int | timeout_s_ |
| std::shared_ptr< ValueProducer< NetworkState > > | network_state_ |
| int | state_observer_id_ = -1 |
| reactesp::RepeatEvent * | poll_event_ = nullptr |
| reactesp::DelayEvent * | restart_event_ = nullptr |
| WiFiWatchdogPolicy | policy_ |
Protected Attributes inherited from sensesp::Saveable | |
| const String | config_path_ |
Restart the device after a prolonged network outage.
Consumes NetworkState from the app's NetworkStateProducer and polls a WiFiWatchdogPolicy once a second. The watchdog arms on the first station or Ethernet connection after boot, so a device that starts without a reachable access point is left running. The soft-AP and the captive portal neither arm the watchdog nor count as an outage. Once armed, a continuous outage of at least the configured timeout restarts the device.
The timeout is persisted under the config path and editable from the web UI. It is read on every poll, so a change takes effect without a restart. A persisted value takes precedence over the constructor argument on later boots.
| network_state | Producer of the link state to watch. |
| timeout_s | Initial outage duration in seconds before restarting. Must satisfy is_valid_timeout_s(); the caller validates. |
| config_path | Path under which the timeout is persisted and shown in the web UI. |
Definition at line 37 of file wifi_watchdog.h.
| sensesp::WiFiWatchdog::WiFiWatchdog | ( | std::shared_ptr< ValueProducer< NetworkState > > | network_state, |
| int | timeout_s, | ||
| const String & | config_path = "/System/WiFi Watchdog" |
||
| ) |
|
virtual |
|
overridevirtual |
Deserializes the current object data from a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 68 of file wifi_watchdog.cpp.
|
inlinestatic |
|
protected |
Definition at line 36 of file wifi_watchdog.cpp.
|
protected |
Definition at line 46 of file wifi_watchdog.cpp.
|
inlineprotected |
|
overridevirtual |
Serializes the current object data into a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 63 of file wifi_watchdog.cpp.
|
staticconstexpr |
Definition at line 40 of file wifi_watchdog.h.
|
protected |
Definition at line 62 of file wifi_watchdog.h.
|
protected |
Definition at line 66 of file wifi_watchdog.h.
|
protected |
Definition at line 64 of file wifi_watchdog.h.
|
protected |
Definition at line 65 of file wifi_watchdog.h.
|
protected |
Definition at line 63 of file wifi_watchdog.h.
|
protected |
Definition at line 61 of file wifi_watchdog.h.