feat(SystemHandler,ConfigManager): add system.set_identity sysadmin command (F-060)
Device identity (serial/hw_family/hw_revision) has been read-only from production firmware since NVS provisioning — serial derives the MQTT password and hw_family/hw_revision select the OTA channel, so an uncontrolled write path could desync MQTT auth or brick OTA to the wrong hardware. This adds one narrow, deliberate exception: an MQTT-only system.set_identity command for correcting a mis-provisioned unit or reassigning a serial after a board swap, without a USB/serial reflash. Rejected over WebSocket/HTTP/UART by design (same pattern as identify's WebSocket-only check); requires all three fields together to avoid partial-identity states; forces a reboot after a successful write since MQTT credentials/hostname/AP SSID are derived from serial only once at boot. Firmware does not update the backend device record itself — that's the caller's (console's) responsibility in the same operation. Also includes docs/README.md's rule 6 (console API reference sync requirement) from an earlier uncommitted session, which this change follows. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,7 @@ Every feature — user-facing or significant internal mechanism — is listed he
|
||||
| F-057 | QA-to-shipping stats reset — `telemetry.reset_boot_data` (lifetime boot count + SD boot log) and `logs.clear` (SD debug logs) | v2.1.6 | Stable |
|
||||
| F-058 | Fix: NTP sync RTC corruption on flaky internet — de-dup guard, retry cooldown, large-jump consensus check | v2.1.7 | Stable |
|
||||
| F-059 | Fix: partition table mismatch blocking safe OTA to pre-restructure field devices | v2.1.7 | Stable |
|
||||
| F-060 | `system.set_identity` — sysadmin override of factory-set device identity (serial/hw_family/hw_revision) | v2.1.7 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -976,3 +977,21 @@ With this in place, OTA to the existing field devices is safe going forward —
|
||||
Verified: `pio run` (all four environments) + manual decode of `partitions.bin` against the field-device `partitions.csv`.
|
||||
|
||||
Subsystem: `platformio.ini`, `no_fs.csv` (new)
|
||||
|
||||
---
|
||||
|
||||
### F-060 — `system.set_identity`: sysadmin override of factory-set device identity
|
||||
|
||||
Device identity (`serial`, `hw_family`, `hw_revision`) has been factory-set-and-read-only since the NVS provisioning work — production firmware loads it once at boot and previously had no write path at all (`ConfigManager::saveDeviceIdentityToNVS()` had been deliberately removed). That's still the right default: `serial` derives the MQTT password (`HMAC-SHA256(MQTT_SECRET, serial)`), and `hw_family`/`hw_revision` select the OTA channel/binary, so an uncontrolled identity change can desync MQTT auth or pull firmware built for the wrong board.
|
||||
|
||||
This adds a narrow, deliberate exception: a new `system.set_identity` command lets a sysadmin overwrite identity on an already-deployed device — e.g. correcting a mis-provisioned unit, or reassigning a serial after a board swap — without a USB/serial reflash.
|
||||
|
||||
**Design constraints, by intent:**
|
||||
- **MQTT-only.** Rejected over WebSocket/HTTP with an explicit transport check in the handler (same pattern as `identify`'s WebSocket-only restriction), and not added to `UARTTransport::WHITELIST`, so UART drops it by default. This means the command is only reachable by publishing to the device's MQTT command topic — i.e. only from the backend/console, not from a device on the local network probing the WebSocket/UART surface.
|
||||
- **All three fields required together.** No partial update. Matches the existing boot-time invariant (`loadDeviceIdentityFromNVS()` already fails if any of the three is empty) — there's no valid state with only some of them set.
|
||||
- **Forces a reboot after a successful write.** MQTT credentials, hostname, and AP SSID are all derived from `serial` once at boot (`ConfigManager::begin()`); they will not recompute live, so the device would otherwise keep authenticating with the *old* derived password after its stored identity already changed. Reply is sent first, then reboot after 2s (same pattern as `system.restart`).
|
||||
- **Firmware does not update the backend.** This command only writes the device's own NVS + in-RAM copy. The backend device record (and re-derived MQTT password) must be updated in the same operation by whatever triggers this command — documented as a caller responsibility in both the handler and `ConfigManager::saveDeviceIdentityToNVS()`.
|
||||
|
||||
Not gated behind an additional `confirm` field in the command body — the console UI is expected to require its own confirmation step before ever publishing this command, so no device-side friction was added on top of that.
|
||||
|
||||
Subsystem: `src/ConfigManager/ConfigManager.hpp`, `src/ConfigManager/ConfigManager.cpp`, `src/Communication/Handlers/SystemHandler/SystemHandler.hpp`, `src/Communication/Handlers/SystemHandler/SystemHandler.cpp`
|
||||
|
||||
Reference in New Issue
Block a user