feat(sfm): Series-3 call-home state and audited enable/disable, live send gated until its frame is verified (phase 4)
- minimateplus.protocol: call_home_enabled(raw) reads byte 5 of the UNESCAPED 0x2C payload (0x01 on / 0x00 off, measured 2026-04-20; anything else None -- bench finding #1's lesson: an escaped byte before it would move the raw index); call_home_image(raw, enabled) is write_image's N + 2 image with byte 5 set and everything else as read, refusing a byte 5 never measured. - MiniMateClient.read_call_home_raw() / write_call_home_image(image) (0x7E then 0x7F, each ack checked, never retried). - Series3Adapter.call_home_state (wake, then 0x2C; no serial read, like status) and change_call_home: the shared change core with a connect() identity check, state 'enabled' / 'disabled' / 'unknown(0xNN)' (unknown sends nothing), the plan showing both exact frames, a snapshot of both unescaped images. - S3_CALL_HOME_FRAME_VERIFIED = False: a live change is refused (501) before any connection until the frame is reproduced from Blastware's (next commit). 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
eeb55effe9
commit
8612cd9df7
5 files changed
+267
-6
No files matched your search
@@ -1127,6 +1127,16 @@ class MiniMateClient:
|
||||
raw = proto.read_call_home_config()
|
||||
return _decode_call_home_config(raw)
|
||||
|
||||
def read_call_home_raw(self) -> bytes:
|
||||
"""The `0x2C` reply payload as read (125 B, kept escapes in), for a
|
||||
read-modify-write (`call_home_image`)."""
|
||||
return self._require_proto().read_call_home_config()
|
||||
|
||||
def write_call_home_image(self, image: bytes) -> None:
|
||||
"""Send a `0x7E` image (`call_home_image`) and its `0x7F` confirm, each ack
|
||||
checked. No retry: what happened is the caller's to read back."""
|
||||
self._require_proto().write_call_home_config(image)
|
||||
|
||||
def set_call_home_config(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -165,6 +165,27 @@ def write_image(sub: int, data: bytes) -> bytes:
|
||||
return image
|
||||
|
||||
|
||||
def call_home_enabled(raw: bytes) -> Optional[bool]:
|
||||
"""The call-home switch of a `0x2C` reply payload, read UNESCAPED (an escaped
|
||||
byte before it would move the raw index -- bench finding #1's lesson): byte 5,
|
||||
0x01 on / 0x00 off (measured 2026-04-20, BE11529). Anything else is None."""
|
||||
image = unescape_reply(bytes(raw))
|
||||
if len(image) <= 5:
|
||||
return None
|
||||
return {0x01: True, 0x00: False}.get(image[5])
|
||||
|
||||
|
||||
def call_home_image(raw: bytes, enabled: bool) -> bytes:
|
||||
"""The `0x7E` image that turns call-home on or off: the block as read
|
||||
(`write_image`, N + 2 bytes, unescaped) with byte 5 set to 0x01 / 0x00 and
|
||||
every other byte as the unit sent it. Refuses a byte 5 never measured."""
|
||||
image = write_image(SUB_CALL_HOME_WRITE, raw)
|
||||
if image[5] not in (0x00, 0x01):
|
||||
raise ValueError(f"call-home byte 5 is 0x{image[5]:02X} -- not a value ever measured "
|
||||
"(0x00 off / 0x01 on); nothing built")
|
||||
return image[:5] + bytes([0x01 if enabled else 0x00]) + image[6:]
|
||||
|
||||
|
||||
# Default timeout values (seconds).
|
||||
# MiniMate Plus is a slow device — keep these generous.
|
||||
DEFAULT_RECV_TIMEOUT = 10.0
|
||||
|
||||
Reference in new issue
Block a user