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:
@@ -39,6 +39,7 @@ CommandResult FirmwareHandler::execute(const CommandEnvelope& envelope) {
|
||||
CommandResult FirmwareHandler::handleFirmwareStatus(const CommandEnvelope& e) {
|
||||
auto validationState = _firmwareValidator.getValidationState();
|
||||
auto currentInfo = _firmwareValidator.getCurrentFirmwareInfo();
|
||||
auto backupInfo = _firmwareValidator.getBackupFirmwareInfo();
|
||||
auto config = _firmwareValidator.getValidationConfig();
|
||||
|
||||
static const char* stateNames[] = {
|
||||
@@ -56,6 +57,14 @@ CommandResult FirmwareHandler::handleFirmwareStatus(const CommandEnvelope& e) {
|
||||
doc["build_date"] = currentInfo.buildDate;
|
||||
doc["ota_channel"] = _configManager.getOtaChannel();
|
||||
|
||||
// Rollback safety-net diagnostics — previously logged only, not queryable remotely.
|
||||
doc["startup_retry_count"] = _firmwareValidator.getStartupRetryCount();
|
||||
doc["max_startup_retries"] = config.maxStartupRetries;
|
||||
doc["runtime_failure_count"] = _firmwareValidator.getRuntimeFailureCount();
|
||||
doc["max_runtime_failures"] = config.maxRuntimeFailures;
|
||||
doc["backup_version"] = backupInfo.version;
|
||||
doc["backup_is_valid"] = backupInfo.isValid;
|
||||
|
||||
bool inTesting = _firmwareValidator.isInTestingMode();
|
||||
doc["can_commit"] = inTesting;
|
||||
doc["can_rollback"] = (validationState != FirmwareValidationState::VALIDATED);
|
||||
|
||||
@@ -262,6 +262,12 @@ public:
|
||||
*/
|
||||
bool isNewFirmwarePending() const;
|
||||
|
||||
/** @brief Number of startup validation retries consumed so far this cycle */
|
||||
uint8_t getStartupRetryCount() const { return _startupRetryCount; }
|
||||
|
||||
/** @brief Number of runtime validation failures consumed so far this cycle */
|
||||
uint8_t getRuntimeFailureCount() const { return _runtimeFailureCount; }
|
||||
|
||||
private:
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
@@ -25,6 +25,8 @@ FirmwareValidator implements a two-phase OTA safety gate for the Vesper firmware
|
||||
| `const esp_partition_t* getRunningPartition() const` | Returns the ESP-IDF partition descriptor for the currently executing partition. |
|
||||
| `const esp_partition_t* getBackupPartition() const` | Returns the ESP-IDF partition descriptor for the inactive OTA partition. |
|
||||
| `bool isNewFirmwarePending() const` | Returns `true` if validation has not yet completed (`STARTUP_PENDING`, `STARTUP_RUNNING`, or `RUNTIME_TESTING`). |
|
||||
| `uint8_t getStartupRetryCount() const` | Number of startup validation retries consumed so far this cycle. Previously logged internally only — now exposed via `firmware.status`. |
|
||||
| `uint8_t getRuntimeFailureCount() const` | Number of runtime validation failures consumed so far this cycle. Previously logged internally only — now exposed via `firmware.status`. |
|
||||
|
||||
---
|
||||
|
||||
@@ -91,7 +93,7 @@ These commands are dispatched through the communication layer and map directly t
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `firmware.status` | Returns current validation state, version, boot count, and whether commit/rollback are available. |
|
||||
| `firmware.status` | Returns current validation state, version, boot count, rollback safety-net diagnostics (`startup_retry_count`, `max_startup_retries`, `runtime_failure_count`, `max_runtime_failures`, `backup_version`, `backup_is_valid`), and whether commit/rollback are available. |
|
||||
| `firmware.commit` | Manually commits firmware. Returns an error if not in testing mode. |
|
||||
| `firmware.rollback` | Forces immediate rollback. Device will reboot. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user