feat(Telemetry,Networking,OTAManager,CommunicationRouter): diagnostics report — CPU temp, WiFi reconnects, OTA state, stack high-water mark
Console requested four more Health-tab metrics beyond F-054's free_heap/ping work. None needed 30s heartbeat freshness, so this adds a separate low-frequency report instead of growing the heartbeat further: published every 5 min to status/info (diagnostics_report) and queryable on-demand via a new telemetry.get_diagnostics command. Only CPU temperature needs local sampling (15s, via a min/max/avg RunningStats accumulator on Telemetry) — a thermal spike could occur and subside entirely within a 5-minute gap. The other three fields are monotonic/self-tracking (WiFi reconnect counter, FreeRTOS's own stack high-water mark, rarely-changing OTA state) so a single read at report time loses no information. Verified: pio run on all four board variants.
This commit is contained in:
@@ -113,7 +113,21 @@ public:
|
||||
|
||||
/** @brief Check if Networking is in healthy state */
|
||||
bool isHealthy() const;
|
||||
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
// DIAGNOSTICS — lifetime WiFi reconnect count + last disconnect reason
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
// Cumulative, in-memory only (resets on reboot — a fresh boot legitimately
|
||||
// starts a new "how flaky has this session been" count; lifetime boot
|
||||
// count already answers "how many times has this device restarted, ever").
|
||||
|
||||
uint32_t getReconnectCount() const { return _reconnectCount; }
|
||||
// Human-readable reason for the most recent disconnect, e.g. "AUTH_EXPIRE"
|
||||
// (via WiFi.disconnectReasonName()). Empty string if no disconnect yet this boot.
|
||||
String getLastDisconnectReason() const { return _lastDisconnectReason; }
|
||||
// millis() at the time of the most recent disconnect, or 0 if none yet this boot.
|
||||
uint32_t getLastDisconnectUptimeMs() const { return _lastDisconnectUptimeMs; }
|
||||
|
||||
// Static instance for callbacks
|
||||
static Networking* _instance;
|
||||
|
||||
@@ -133,6 +147,11 @@ private:
|
||||
bool _ethernetCableConnected;
|
||||
int _wifiConnectionFailures; // Track consecutive WiFi failures
|
||||
bool _triedSavedCredentials; // True once saved-creds phase has been exhausted
|
||||
|
||||
// Diagnostics — see getReconnectCount() etc. above
|
||||
uint32_t _reconnectCount = 0;
|
||||
String _lastDisconnectReason = "";
|
||||
uint32_t _lastDisconnectUptimeMs = 0;
|
||||
|
||||
// Callbacks
|
||||
std::function<void()> _onNetworkConnected;
|
||||
|
||||
Reference in New Issue
Block a user