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:
2026-07-20 20:09:39 +03:00
co-authored by Claude Sonnet 5
parent 28b175b4fc
commit 64a8bc2b88
7 changed files with 174 additions and 8 deletions
+9 -3
View File
@@ -321,9 +321,10 @@ public:
const ClockConfig& getClockConfig() const { return clockConfig; }
const GeneralConfig& getGeneralConfig() const { return generalConfig; }
// Device identity methods (READ-ONLY - factory set via separate factory firmware)
// These values are loaded ONCE at boot from NVS and kept in RAM
// Production firmware CANNOT modify device identity
// Device identity getters — factory-set via separate factory firmware, loaded
// ONCE at boot from NVS and kept in RAM. Not writable through normal config
// flows; the only write path is saveDeviceIdentityToNVS() below, reserved for
// the sysadmin-only system.set_identity command.
String getSerial() const { return deviceConfig.serial; }
String getHwFamily() const { return deviceConfig.hwFamily; }
String getHwRevision() const { return deviceConfig.hwRevision; }
@@ -336,6 +337,11 @@ public:
String getFwVersion() const { return FW_VERSION; }
// No-op: version is compiled in, not stored. Kept for call-site compatibility.
void setFwVersion(const String&) {}
// Sysadmin override: overwrites factory-set device identity in NVS and in RAM.
// Gated to the system.set_identity command (MQTT-only). Caller is responsible
// for updating the backend device record to match — this call does not.
bool saveDeviceIdentityToNVS(const String& serial, const String& hwFamily, const String& hwRevision);
// Configuration update methods for app commands
void updateTimeConfig(long gmtOffsetSec, int daylightOffsetSec);