Internet Health Checker class for periodic connectivity monitoring.
More...
#include <gateway.hpp>
Internet Health Checker class for periodic connectivity monitoring.
This class performs periodic TCP connection tests to verify Internet connectivity. It is designed to be non-blocking and work with the TaskScheduler for asynchronous operation.
PLATFORM SUPPORT:
- ESP32/ESP8266: Uses WiFiClient for actual TCP connections
- PC/Test: Mocked connectivity (always fails in test environment)
Example usage:
Serial.printf("Internet %s\n", available ? "connected" : "disconnected");
});
checker.start(scheduler);
Internet Health Checker class for periodic connectivity monitoring.
Definition gateway.hpp:498
void onConnectivityChanged(InternetChangedCallback_t callback)
Register callback for connectivity changes.
Definition gateway.hpp:547
void setConfig(const SharedGatewayConfig &config)
Configure the health checker with gateway settings.
Definition gateway.hpp:506
◆ InternetHealthChecker()
| painlessmesh::gateway::InternetHealthChecker::InternetHealthChecker |
( |
| ) |
|
|
default |
◆ checkNow()
| bool painlessmesh::gateway::InternetHealthChecker::checkNow |
( |
| ) |
|
|
inline |
Perform an immediate Internet connectivity check.
This method performs a synchronous TCP connection test. On ESP32/ESP8266, it uses WiFiClient. In test environment, connectivity is mocked.
- Returns
- true if connection succeeded
◆ checkOnDemand()
| bool painlessmesh::gateway::InternetHealthChecker::checkOnDemand |
( |
| ) |
|
|
inline |
Probe once outside the schedule, for a caller that needs the answer now (issue #450)
A bridge's first periodic probe runs while its station is still associating and fails, and the next is a full interval away. A send in that window may spend one extra probe to learn that the uplink has come up since. One: the probe is a blocking connect with a timeout, so the budget is a single on-demand probe per periodic one. A node whose uplink really is down pays it once per interval, not on every call.
- Returns
- true if Internet is reachable now
◆ getCheckHost()
| TSTRING painlessmesh::gateway::InternetHealthChecker::getCheckHost |
( |
| ) |
const |
|
inline |
Get check host.
- Returns
- Host being checked
◆ getCheckInterval()
| uint32_t painlessmesh::gateway::InternetHealthChecker::getCheckInterval |
( |
| ) |
const |
|
inline |
Get check interval.
- Returns
- Check interval in milliseconds
◆ getCheckPort()
| uint16_t painlessmesh::gateway::InternetHealthChecker::getCheckPort |
( |
| ) |
const |
|
inline |
Get check port.
- Returns
- Port being checked
◆ getCheckTimeout()
| uint32_t painlessmesh::gateway::InternetHealthChecker::getCheckTimeout |
( |
| ) |
const |
|
inline |
Get check timeout.
- Returns
- Check timeout in milliseconds
◆ getStatus()
| InternetStatus painlessmesh::gateway::InternetHealthChecker::getStatus |
( |
| ) |
const |
|
inline |
Get detailed Internet status.
- Returns
- InternetStatus structure with full details
◆ hasLocalInternet()
| bool painlessmesh::gateway::InternetHealthChecker::hasLocalInternet |
( |
| ) |
const |
|
inline |
Check if local Internet is currently available.
- Returns
- true if last check succeeded
◆ onConnectivityChanged()
Register callback for connectivity changes.
- Parameters
-
| callback | Function to call when connectivity status changes |
◆ resetStats()
| void painlessmesh::gateway::InternetHealthChecker::resetStats |
( |
| ) |
|
|
inline |
◆ setCheckInterval()
| void painlessmesh::gateway::InternetHealthChecker::setCheckInterval |
( |
uint32_t |
intervalMs | ) |
|
|
inline |
Set check interval.
- Parameters
-
| intervalMs | Interval between checks in milliseconds |
◆ setCheckTarget()
| void painlessmesh::gateway::InternetHealthChecker::setCheckTarget |
( |
const TSTRING & |
host, |
|
|
uint16_t |
port = 53 |
|
) |
| |
|
inline |
Set custom check host and port.
- Parameters
-
| host | Host to check (IP address or hostname) |
| port | Port to connect to (default: 53 for DNS) |
◆ setCheckTimeout()
| void painlessmesh::gateway::InternetHealthChecker::setCheckTimeout |
( |
uint32_t |
timeoutMs | ) |
|
|
inline |
Set check timeout.
- Parameters
-
| timeoutMs | Timeout for each check in milliseconds |
◆ setConfig()
| void painlessmesh::gateway::InternetHealthChecker::setConfig |
( |
const SharedGatewayConfig & |
config | ) |
|
|
inline |
Configure the health checker with gateway settings.
- Parameters
-
The documentation for this class was generated from the following file: