feat(FirmwareValidator): expose rollback safety-net diagnostics via firmware.status
Startup retry count, runtime failure count, and backup partition info were tracked internally (NVS-persisted) but only visible via LOG_* output — not queryable remotely. Added getStartupRetryCount()/getRuntimeFailureCount() getters and extended firmware.status with startup_retry_count, max_startup_retries, runtime_failure_count, max_runtime_failures, backup_version, backup_is_valid. F-049 in the feature catalog. Also finalizes the feature-catalog.md and api-reference.md updates for F-045/F-046/F-047/F-048 from the two prior commits (doc content is consolidated into this final commit rather than split across the changeset).
This commit is contained in:
@@ -54,6 +54,11 @@ Every feature — user-facing or significant internal mechanism — is listed he
|
||||
| F-042 | Combined clock config commands (`clock.set_config` / `clock.set_alerts_config`) | v2.1.1 | Stable |
|
||||
| F-043 | `network.info` expanded — subnet, MAC, hostname, SSID, connection type | v2.1.1 | Stable |
|
||||
| F-044 | `network.status` slimmed — pure runtime state (connected, state, RSSI, uptime, AP mode) | v2.1.1 | Stable |
|
||||
| F-045 | Day-rotated SD log files with size cap (`/logs/YYYY-MM-DD.log`) | v2.1.2 | Stable |
|
||||
| F-046 | Boot reset-reason capture, routed to alerts (fault) or info (expected) | v2.1.2 | Stable |
|
||||
| F-047 | Per-subsystem MQTT log rate limiting (token bucket + drop summary) | v2.1.2 | Stable |
|
||||
| F-048 | SD log retrieval commands (`logs.list` / `logs.download`) | v2.1.2 | Stable |
|
||||
| F-049 | `firmware.status` rollback safety-net diagnostics (retry/failure counts, backup partition) | v2.1.2 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -607,3 +612,60 @@ Subsystem: `src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp`
|
||||
Removed from `network.status`: `ip`, `mac`, `hostname`, `ssid`, `type` — these are static addressing facts, now served by `network.info`.
|
||||
|
||||
Subsystem: `src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-045 — Day-rotated SD log files with size cap
|
||||
|
||||
Fixes a bug where SD logging was a silent no-op: `FileManager::appendLine` never created the `/logs` directory before opening the file in append mode, which fails on most SD/FAT implementations when the parent directory doesn't exist.
|
||||
|
||||
New `FileManager::appendLogLine(logDir, line, timestamp, maxTotalBytes)` replaces the direct `appendLine` call as the SD log channel's write path:
|
||||
- Ensures `logDir` exists before every write.
|
||||
- Names the file `YYYY-MM-DD.log` from the supplied timestamp (`time(nullptr)`, works with or without an RTC once NTP has synced). Falls back to `unset-date.log` if no wall clock is available yet, rather than dropping early-boot lines.
|
||||
- Prunes oldest whole files once the directory exceeds a 512KB total budget (`SD_LOG_MAX_TOTAL_BYTES` in `CommunicationRouter.cpp`).
|
||||
|
||||
Subsystems: `src/FileManager/FileManager.cpp`, `src/Communication/CommunicationRouter/CommunicationRouter.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-046 — Boot reset-reason capture
|
||||
|
||||
`Telemetry::begin()` now reads `esp_reset_reason()` at the very start of boot, before anything else can crash again this cycle. Classified into fault (`ESP_RST_PANIC`, `ESP_RST_INT_WDT`, `ESP_RST_TASK_WDT`, `ESP_RST_WDT`, `ESP_RST_BROWNOUT`) vs expected (power-on, software reset/OTA, deep sleep wake, etc).
|
||||
|
||||
- Persisted in the SD boot log (`/telemetry_boot_log.json`, field `reason`) regardless of connectivity — works for offline devices.
|
||||
- For online devices, `CommunicationRouter::reportBootReasonOnce()` fires the first time MQTT connects after boot (registered via `MQTTDriver::setOnConnectCallback`): fault reasons publish to `vesper/{uid}/status/alerts`, expected reasons publish to `vesper/{uid}/status/info` (event type `boot_reason`). Fires once per boot, not on every reconnect.
|
||||
|
||||
Subsystems: `src/Telemetry/Telemetry.cpp`, `src/Communication/CommunicationRouter/CommunicationRouter.cpp`, `src/Communication/Drivers/MQTTDriver/MQTTDriver.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-047 — Per-subsystem MQTT log rate limiting
|
||||
|
||||
Token bucket per subsystem tag on the MQTT log channel (burst of 10, refills 1/second) inside `Logging::publishToMqtt()`. Protects the broker/airtime from a chatty or misconfigured subsystem (e.g. a per-subsystem override left at VERBOSE via `log.set_mqtt`).
|
||||
|
||||
Drops are counted, not silently discarded: the next time a rate-limited tag is allowed to publish again, a `WARNING` summary line (`"suppressed N log message(s) (MQTT rate limit)"`) is emitted first. Serial and SD channels are unaffected — MQTT only.
|
||||
|
||||
Subsystem: `src/Logging/Logging.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-048 — SD log retrieval commands (`logs.list` / `logs.download`)
|
||||
|
||||
Two new commands on `LoggingHandler` for pulling day-rotated SD logs off a device remotely (offline-device troubleshooting workflow: app queries device directly, or backend requests once the device is back online).
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `logs.list` | Lists dated log files under `/logs` with name + size. |
|
||||
| `logs.download` | Returns a bounded chunk (`{file, offset}` → `{data, next_offset, eof}`) of a log file. Callers loop, feeding `next_offset` back as `offset`, until `eof` is true. Rejects path traversal in `file`. |
|
||||
|
||||
Chunked rather than whole-file because `CommandResult` JSON payloads need to stay small regardless of file size (a rotated file can be up to the full SD log budget). Both commands return an error (not a crash) on boards without an SD card — `LoggingHandler` now takes an optional `FileManager*`.
|
||||
|
||||
Subsystems: `src/Communication/Handlers/LoggingHandler/LoggingHandler.cpp`, `src/FileManager/FileManager.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-049 — `firmware.status` rollback safety-net diagnostics
|
||||
|
||||
`FirmwareValidator` tracked startup retry count, runtime failure count, and backup partition info internally (NVS-persisted) but never exposed them remotely — only visible via `LOG_*` output. Added public getters (`getStartupRetryCount()`, `getRuntimeFailureCount()`) and extended `firmware.status` with `startup_retry_count`, `max_startup_retries`, `runtime_failure_count`, `max_runtime_failures`, `backup_version`, `backup_is_valid`.
|
||||
|
||||
Subsystems: `src/FirmwareValidator/FirmwareValidator.hpp`, `src/Communication/Handlers/FirmwareHandler/FirmwareHandler.cpp`
|
||||
|
||||
Reference in New Issue
Block a user