fix(reporter,docs): save config before applying; correct README trust-model

Reorder reporter_heartbeat so NVS persistence commits before in-RAM apply.
If save fails, log and return without touching runtime state; RAM and NVS
stay consistent on the prior version instead of diverging until reboot.

Rewrite README "Trust model" to state reality: reporting is plain HTTP and
HMAC signs only requests, not responses. A LAN-local MITM can push any
config that passes the device range validator. Add roadmap entry for
authenticated config push (HTTPS or signed envelope).
This commit is contained in:
2026-04-16 17:47:41 -07:00
parent bcb02b6d73
commit e5eeea2b47
2 changed files with 10 additions and 6 deletions

View File

@@ -236,12 +236,12 @@ void reporter_heartbeat(const DeviceConfig& cfg, uint32_t uptime_s, int wifi_rss
return;
}
cv_apply_tuning(candidate);
if (!config_save_tuning(candidate)) {
Serial.printf("[CFG] applied v=%u but NVS save failed\n", (unsigned)new_ver);
} else {
Serial.printf("[CFG] applied v=%u\n", (unsigned)new_ver);
Serial.printf("[CFG] rejected v=%u: NVS save failed\n", (unsigned)new_ver);
return;
}
cv_apply_tuning(candidate);
Serial.printf("[CFG] applied v=%u\n", (unsigned)new_ver);
}
void reporter_flush(const DeviceConfig& cfg) {