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:
2026-07-15 00:04:42 +03:00
parent 85cdc55b78
commit 7675a67c90
5 changed files with 123 additions and 2 deletions
+43 -1
View File
@@ -459,7 +459,9 @@ Get firmware validation state.
| | |
|---|---|
| Returns | `{ "validation_state", "version", "boot_count", "can_commit", "can_rollback" }` |
| Returns | `{ "validation_state", "current_version", "is_testing", "is_valid", "boot_count", "build_date", "ota_channel", "startup_retry_count", "max_startup_retries", "runtime_failure_count", "max_runtime_failures", "backup_version", "backup_is_valid", "can_commit", "can_rollback", "runtime_timeout_ms"? }` |
`startup_retry_count`, `runtime_failure_count`, and the backup partition fields are the OTA rollback safety-net's internal counters — previously only visible via serial/SD log output, now queryable remotely. Useful for diagnosing why a device rolled back an update. `runtime_timeout_ms` is only present while `is_testing` is true.
```json
{ "v": 2, "cmd": "firmware.status" }
@@ -701,6 +703,38 @@ Set log verbosity per output channel. Level 0 = off, 5 = verbose.
---
### `logs.list`
List day-rotated SD log files (`/logs/YYYY-MM-DD.log`). Requires an SD card — returns an error on boards without one.
| | |
|---|---|
| Returns | `{ "files": [{ "name": "2026-07-14.log", "size": 1234 }, ...] }` |
```json
{ "v": 2, "cmd": "logs.list" }
```
---
### `logs.download`
Read a bounded chunk of a log file. Responses are capped at 4096 bytes regardless of file size — callers loop, feeding `next_offset` back in as `offset`, until `eof` is `true`. Requires an SD card.
| | |
|---|---|
| Required | `file` (string) — bare filename as returned by `logs.list`, no path separators |
| Optional | `offset` (int, default `0`) |
| Returns | `{ "file", "data", "next_offset", "eof" }` |
```json
{ "v": 2, "cmd": "logs.download", "contents": { "file": "2026-07-14.log", "offset": 0 } }
```
Loop example: keep calling with `contents.offset = <previous next_offset>` until the response has `"eof": true`.
---
## RF Remote Namespace — `RFRemoteHandler`
> Available on hardware variants with `HAS_RF=1` (e.g. Vesper, Vesper+).
@@ -954,6 +988,11 @@ On recovery:
`state` values: `WARNING` | `CRITICAL` | `FAILED` | `CLEARED`
A fault-class boot reset also publishes here — `subsystem: "System"`, e.g.:
```json
{ "subsystem": "System", "state": "WARNING", "msg": "Device reset due to fault: TASK_WATCHDOG" }
```
### Info Payload (`vesper/{id}/status/info`)
Published on significant device state changes. `type` identifies the event; `payload` is event-specific.
@@ -961,8 +1000,11 @@ Published on significant device state changes. `type` identifies the event; `pay
```json
{ "type": "playback_started", "payload": { "pid": "ormilia_1_8" } }
{ "type": "playback_stopped", "payload": {} }
{ "type": "boot_reason", "payload": { "reason": "POWERON" } }
```
`boot_reason` is published once, the first time MQTT connects after boot — only for expected reset reasons (`POWERON`, `SOFTWARE`, `DEEPSLEEP_WAKE`, `EXTERNAL_PIN`, `SDIO`, `UNKNOWN`). Fault reasons (`PANIC`, `TASK_WATCHDOG`, `INTERRUPT_WATCHDOG`, `OTHER_WATCHDOG`, `BROWNOUT`) go to `status/alerts` instead (see above).
---
## Legacy Compatibility (v1)