fix(sfm): a monitoring MiniMate's call-home says 'stop monitoring first', not 'unknown(0x6E)'

Measured at the bench 2026-11-03 (BE9441): while monitoring, a MiniMate answers
the 0x2C call-home read with its DEVICE-INFO block ('Instantel', 'MiniMate Plus',
its serial) -- as it answers 1A -- and idle again, minutes later, the call-home
block.  SFM writes back only a block it just read, so a monitoring MiniMate's
call-home cannot be changed; the change core already refused (byte 5 read as
'unknown(0x6E)', nothing sent), but said so cryptically.

- minimateplus.protocol.is_call_home_block(raw): the block starts with its own
  length 0x7C and is N (or N + 2) bytes unescaped; the device-info block fails it.
- The Series-3 change raises UnitStateUnknown (409) with 'did not return its
  call-home settings -- a MiniMate answers the call-home read with its
  device-info block while monitoring; stop monitoring first ... nothing sent',
  for a dry run too.  call_home_state returns enabled = None with that reason.
- The page's callHomeRows shows the reason in place of 'Unknown (byte 5 = ...)'.

A blind write while monitoring stays untested on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-03 14:19:19 -05:00
1 parent 9820a5389f
commit 5326e99ac2
5 files changed
+71 -6

No files matched your search

+11
View File
@@ -169,6 +169,17 @@ class ImageRefused(ValueError):
"""A write refused before any byte was sent: the image is not a whole block."""
def is_call_home_block(raw: bytes) -> bool:
"""Whether a 0x2C reply payload is the call-home block: it starts with its own
length N = 0x7C (00 7C DC on every read on record) and is N (or N + 2) bytes
unescaped. A MONITORING MiniMate answers the read with its device-info block
instead (00 00 00 08 'Instantel' ..., measured 2026-11-03 on BE9441), which
fails this."""
image = unescape_reply(bytes(raw))
n = DATA_LENGTHS[SUB_CALL_HOME]
return len(image) >= 3 and int.from_bytes(image[:2], "big") == n and len(image) in (n, n + 2)
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,
+17 -5
View File
@@ -13,12 +13,12 @@ from minimateplus.event_file_io import _GEO_INT16_FS
from minimateplus.framing import build_bw_write_frame, unescape_reply
from minimateplus.protocol import (
SUB_CALL_HOME_CONFIRM, SUB_CALL_HOME_WRITE, SUB_START_MONITORING, SUB_STOP_MONITORING,
ImageRefused, call_home_enabled, call_home_image, write_image,
ImageRefused, call_home_enabled, call_home_image, is_call_home_block, write_image,
)
from minimateplus.transport import TcpTransport
from .errors import (DeviceError, EventNotFound, MalformedReply, NoAnswer, NotSupported, StaleEvent,
WrongUnit, translate)
UnitStateUnknown, WrongUnit, translate)
from .change import call_home_change, monitoring_change, run_change
from .events import iso_of, make_event_id, stamp_of
from .models import (CallHomeState, ChangeResult, DownloadedEvent, EventList, EventRef, UnitAddress,
@@ -39,6 +39,13 @@ S3_EVENT_TIMEOUT = 120.0 # what the legacy event-download routes use
# writes (BE11529, 2026-04-20) byte for byte from the unit's own reads.
S3_CALL_HOME_FRAME_VERIFIED = True
# Measured 2026-11-03 (BE9441): while monitoring, a MiniMate answers the 0x2C read
# with its device-info block, as it answers 1A -- its call-home settings cannot be
# read, so they cannot be changed (SFM writes back only a block it just read).
S3_CALL_HOME_WHILE_MONITORING = ("did not return its call-home settings -- a MiniMate answers the "
"call-home read with its device-info block while monitoring; "
"stop monitoring first, then change call-home")
# The 0x1C flag byte (section[1]): the only values ever measured. 0x10 is
# BE11529 monitoring (2026-04-08); 0x0B is BE9441 recording a histogram,
# confirmed at the unit (2026-10-26). Anything else is refused for a change.
@@ -349,11 +356,14 @@ class Series3Adapter:
client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S)
raw = client.read_call_home_raw()
image = unescape_reply(raw)
detail = {"byte5": f"0x{image[5]:02X}" if len(image) > 5 else None,
"block": bytes(raw).hex(), "serial_verified": False}
if not is_call_home_block(raw):
detail["reason"] = f"the unit {S3_CALL_HOME_WHILE_MONITORING}"
return CallHomeState(serial=serial, series=3, enabled=None, dial_string=None, detail=detail)
dial = bytes(image[6:46]).split(b"\x00", 1)[0].decode("ascii", errors="replace") or None
return CallHomeState(serial=serial, series=3, enabled=call_home_enabled(raw),
dial_string=dial,
detail={"byte5": f"0x{image[5]:02X}" if len(image) > 5 else None,
"block": bytes(raw).hex(), "serial_verified": False})
dial_string=dial, detail=detail)
return self._run(address, op)
def change_call_home(self, address: UnitAddress, serial: str, *, enabled: bool, dry_run: bool,
@@ -378,6 +388,8 @@ class Series3Adapter:
def read_state() -> str:
client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S)
raw = client.read_call_home_raw()
if not is_call_home_block(raw):
raise UnitStateUnknown(f"{serial} {S3_CALL_HOME_WHILE_MONITORING} -- nothing sent")
reads.append(raw)
on = call_home_enabled(raw)
if on is None:
+2 -1
View File
@@ -204,8 +204,9 @@ function serialPanes(bySerial, settingsRead) {
// enable byte never measured -- shown with the byte, never as On or Off.
function callHomeRows(state) {
const s = state || {};
const d = s.detail || {};
const sw = s.enabled === true ? 'On' : s.enabled === false ? 'Off'
: `Unknown (byte 5 = ${(s.detail || {}).byte5 ?? '?'})`;
: d.reason || `Unknown (byte 5 = ${d.byte5 ?? '?'})`;
return [['Call-home', sw], ['Dial string', s.dial_string || '—'], ['Series', s.series]];
}
/* </device-routing> */
+34
View File
@@ -145,3 +145,37 @@ def test_a_pre_wire_refusal_is_recorded_as_nothing_sent():
((_, row),) = audit.rows.items()
assert (row["outcome"], row["sent"]) == ("failed", 0)
assert row["error"].startswith("refused before sending")
# Measured 2026-11-03 (BE9441): while monitoring, a MiniMate answers the 0x2C read
# with its DEVICE-INFO block ("Instantel", "MiniMate Plus", its serial), not its
# call-home block -- as it answers 1A. Idle again, it returns the call-home block.
# SFM says so plainly instead of "run state unknown(0x6E)".
def device_info_shaped(serial=b"BE9441"):
"""Shaped like BE9441's reply (its first bytes: 00 00 00 08 'Instantel')."""
block = b"\x00\x00\x00\x08Instantel".ljust(26, b"\x00") + b"MiniMate Plus".ljust(16, b"\x00") + serial
return block.ljust(126, b"\x00")
def test_a_call_home_block_is_told_from_the_device_info_block():
from minimateplus.protocol import is_call_home_block
assert is_call_home_block(s3_call_home_raw()) is True
assert is_call_home_block(device_info_shaped()) is False
@pytest.mark.parametrize("dry_run", [True, False])
def test_a_monitoring_minimate_is_told_to_stop_first_and_nothing_is_sent(dry_run):
fake = FakeMiniMateClient(call_home_raw=device_info_shaped())
with pytest.raises(UnitStateUnknown) as e:
change(adapter(fake), enabled=True, dry_run=dry_run)
msg = str(e.value)
assert "monitoring" in msg and "stop" in msg and "nothing sent" in msg
assert e.value.http_status == 409 and fake.writes == []
def test_the_call_home_state_of_a_monitoring_minimate_says_why():
st = adapter(FakeMiniMateClient(call_home_raw=device_info_shaped())).call_home_state(TCP, "BE18193")
assert st.enabled is None
assert "monitoring" in st.detail["reason"]
+7
View File
@@ -327,3 +327,10 @@ def test_call_home_rows():
assert r[0] == [["Call-home", "On"], ["Dial string", "RADIO RING"], ["Series", 4]]
assert r[1] == [["Call-home", "Off"], ["Dial string", "—"], ["Series", 3]]
assert r[2][0] == ["Call-home", "Unknown (byte 5 = 0x07)"]
def test_call_home_rows_say_why_a_switch_did_not_read():
r = run(["callHomeRows", [{"enabled": None, "dial_string": None, "series": 3,
"detail": {"byte5": "0x6E", "reason": "not readable while monitoring -- stop it first"}}]])
assert r[0][0] == ["Call-home", "not readable while monitoring -- stop it first"]