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:
@@ -449,6 +449,33 @@ Reboot the device. Response is sent before reboot (2s delay).
|
||||
|
||||
---
|
||||
|
||||
### `system.set_identity`
|
||||
|
||||
Overwrite the device's factory-set identity (`serial`, `hw_family`, `hw_revision`) in NVS and reboot to apply it. Intended for sysadmin use only — e.g. reassigning a serial after a board swap, or correcting a mis-provisioned unit — via the backend console, which is responsible for updating its own device record (including re-deriving the MQTT password from the new serial) in the same operation. Firmware does not touch the backend record itself.
|
||||
|
||||
> **Warning:** Non-reversible from the device's perspective, and dangerous if the backend device record isn't updated to match — a serial mismatch will break MQTT auth (password is derived from serial), and a wrong `hw_family`/`hw_revision` can pull an OTA build for the wrong hardware. Device restarts 2s after a successful response to apply the new identity.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Handler | SystemHandler |
|
||||
| Transports | MQTT only |
|
||||
| Contents | `serial` (required), `hw_family` (required), `hw_revision` (required) |
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "system.set_identity", "contents": { "serial": "PV000000000001", "hw_family": "VS", "hw_revision": "01" } }
|
||||
```
|
||||
|
||||
**Errors:**
|
||||
|
||||
| Message | Condition |
|
||||
|---|---|
|
||||
| `system.set_identity is only available via MQTT` | Sent over WebSocket, HTTP, or UART |
|
||||
| `Missing required fields: serial, hw_family, hw_revision (all required)` | One or more fields absent or not a string |
|
||||
| `serial, hw_family and hw_revision must be non-empty` | One or more fields present but empty |
|
||||
| `Failed to persist new identity to NVS — device identity unchanged` | NVS write/commit failed |
|
||||
|
||||
---
|
||||
|
||||
## Firmware Namespace — `FirmwareHandler`
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user