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
+20
View File
@@ -9,6 +9,25 @@
#include <nvs.h>
#include <esp_task_wdt.h>
const char* OTAManager::errorCodeToString(ErrorCode code) {
switch (code) {
case ErrorCode::NONE: return "NONE";
case ErrorCode::HTTP_ERROR: return "HTTP_ERROR";
case ErrorCode::VERSION_CHECK_FAILED: return "VERSION_CHECK_FAILED";
case ErrorCode::DOWNLOAD_FAILED: return "DOWNLOAD_FAILED";
case ErrorCode::INSUFFICIENT_SPACE: return "INSUFFICIENT_SPACE";
case ErrorCode::WRITE_FAILED: return "WRITE_FAILED";
case ErrorCode::VERIFICATION_FAILED: return "VERIFICATION_FAILED";
case ErrorCode::CHECKSUM_MISMATCH: return "CHECKSUM_MISMATCH";
case ErrorCode::METADATA_PARSE_FAILED: return "METADATA_PARSE_FAILED";
case ErrorCode::SIZE_MISMATCH: return "SIZE_MISMATCH";
case ErrorCode::VERSION_TOO_LOW: return "VERSION_TOO_LOW";
case ErrorCode::CHANNEL_MISMATCH: return "CHANNEL_MISMATCH";
case ErrorCode::PLAYER_ACTIVE: return "PLAYER_ACTIVE";
default: return "UNKNOWN";
}
}
OTAManager::OTAManager(ConfigManager& configManager)
: _configManager(configManager)
, _fileManager(nullptr)
@@ -225,6 +244,7 @@ void OTAManager::checkForUpdates(const String& channel) {
}
setStatus(Status::CHECKING_VERSION);
_lastCheckUptimeMs = millis();
LOG_INFO(TAG, "Checking for firmware updates in %s channel for %s...",
channel.c_str(), _configManager.getHardwareVariant().c_str());
+8
View File
@@ -103,6 +103,13 @@ public:
SemVer getCurrentVersion() const;
SemVer getAvailableVersion() const { return _availableVersion; }
bool isUpdateAvailable() const { return _updateAvailable; }
// millis() at the start of the most recent update-check attempt (scheduled,
// emergency, or manual), or 0 if no check has run yet this boot.
uint32_t getLastCheckUptimeMs() const { return _lastCheckUptimeMs; }
// Human-readable name for an ErrorCode, e.g. "DOWNLOAD_FAILED". Used by
// diagnostics_report and telemetry.get_diagnostics.
static const char* errorCodeToString(ErrorCode code);
// Callbacks
void setProgressCallback(ProgressCallback callback) { _progressCallback = callback; }
@@ -129,6 +136,7 @@ private:
SemVer _minVersion;
size_t _expectedFileSize; // NEW: Expected firmware file size
bool _updateAvailable;
uint32_t _lastCheckUptimeMs = 0; // See getLastCheckUptimeMs()
String _availableChecksum;
String _availableDownloadPath; // Relative path from backend (e.g. /api/firmware/.../firmware.bin)
String _updateChannel;