feat(s4): change a Micromate's settings by serial, audited, schedule-checked
s4_change_settings runs the shared change core with a read-back verdict for its state (as asked / unchanged / differs). It reads the active setup's name (unstripped), the preferences, trigger and setup blocks and the schedule; patches the setup through micromate.setup_fields; sends THOR's setup push (0xDA 68 73 82 83 71 72, now enableable) once; reads the setup back. Refused before sending: a monitoring unit, a value the unit does not allow (422), a stale preview (SettingsChanged, 409), and -- shown as 'blocked' in the preview -- the factory setup, a schedule that loads another setup, an unreadable schedule, or a block SFM has not seen (ChangeRefused, 409). s4_settings carries the editable fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
d0335dbbbd
commit
c082f72d62
9 files changed
+407
-16
No files matched your search
@@ -86,7 +86,10 @@ READ_SUBS: Mapping[int, str] = MappingProxyType(_READ_SUBS)
|
||||
# (0xA8/0xAA), raw file writes (0x8D/0x8E -- they could reach the modem
|
||||
# settings) and 0xA2 never belong here without one. Phase 4 (2026-11-02) added
|
||||
# the call-home write and its confirm (spec row 9: enable/disable only).
|
||||
ENABLEABLE_WRITES = frozenset({0x96, 0x97, 0x7E, 0x7F})
|
||||
# Phase 5 (2026-11-03) added the setup push -- name, preferences, trigger and setup
|
||||
# blocks with their confirms -- for changing a unit's settings by serial (spec row 10).
|
||||
ENABLEABLE_WRITES = frozenset({0x96, 0x97, 0x7E, 0x7F,
|
||||
0xDA, 0x68, 0x73, 0x82, 0x83, 0x71, 0x72}) # + the setup push (phase 5)
|
||||
|
||||
|
||||
class OpcodeRefused(RuntimeError):
|
||||
|
||||
@@ -233,6 +233,21 @@ def field_values(content: bytes, series: int) -> Dict[str, Any]:
|
||||
return {d["field"]: d["value"] for d in editable_fields(content, series)}
|
||||
|
||||
|
||||
def field_rows(before: bytes, written: bytes, series: int, fields, now: Optional[bytes] = None) -> Dict[str, Dict[str, Any]]:
|
||||
"""For each changed field: its label, the value the unit had (old), the value
|
||||
sent (new) and, given a read-back, what the unit now holds (now)."""
|
||||
a, w = field_values(before, series), field_values(written, series)
|
||||
n = field_values(now, series) if now is not None else None
|
||||
labels = {d["field"]: d["label"] for d in editable_fields(written, series)}
|
||||
out: Dict[str, Dict[str, Any]] = {}
|
||||
for f in fields:
|
||||
row: Dict[str, Any] = {"label": labels[f], "old": a[f], "new": w[f]}
|
||||
if n is not None:
|
||||
row["now"] = n[f]
|
||||
out[f] = row
|
||||
return out
|
||||
|
||||
|
||||
# ── Checking ────────────────────────────────────────────────────────────────
|
||||
|
||||
def _number(field: str, v: Any) -> float:
|
||||
|
||||
Reference in new issue
Block a user