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:
2026-07-17 13:09:16 +03:00
parent 9cd6b142ef
commit 959cb77d81
14 changed files with 388 additions and 9 deletions
+17 -3
View File
@@ -371,9 +371,18 @@ void Networking::onEthernetDisconnected() {
void Networking::onWiFiConnected() {
LOG_INFO(TAG, "WiFi connected successfully - IP: %s", WiFi.localIP().toString().c_str());
// A "reconnect" is any successful connect AFTER the initial boot-time
// connection — _bootSequenceComplete is only true once that first
// connection has already happened, so this correctly excludes it.
if (_bootSequenceComplete) {
_reconnectCount++;
LOG_INFO(TAG, "WiFi reconnected (lifetime count this boot: %lu)", _reconnectCount);
}
setState(NetworkState::CONNECTED_WIFI);
setActiveConnection(ConnectionType::WIFI);
// Reset failure/phase counters on successful connection
_wifiConnectionFailures = 0;
_triedSavedCredentials = false;
@@ -512,10 +521,15 @@ void Networking::networkEventHandler(arduino_event_id_t event, arduino_event_inf
_instance->onWiFiConnected();
break;
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
LOG_WARNING(TAG, "WiFi Disconnected");
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: {
wifi_err_reason_t reason = (wifi_err_reason_t)info.wifi_sta_disconnected.reason;
const char* reasonName = WiFi.disconnectReasonName(reason);
LOG_WARNING(TAG, "WiFi Disconnected (reason: %s)", reasonName);
_instance->_lastDisconnectReason = reasonName;
_instance->_lastDisconnectUptimeMs = millis();
_instance->onWiFiDisconnected();
break;
}
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
LOG_DEBUG(TAG, "WiFi STA Connected");