feat(sfm): opt-in raw SUB 0x49 code on a Series-4 status read
GET /device/monitor/status?serial=UM...&run_state=true adds
detail.run_state = {code, name}. For the ring-path bench test: the code
during and after a call-home (0x01 for ~18 s after a stop, inferred to be
call-home attempts; 0x03 = calling home) is what the test watches. Opt-in
because it is one more round trip (~0.65 s on cellular); a plain status read
is unchanged. Series 3 has no 0x49 and ignores it.
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
2560ef4586
commit
ee02874cb0
5 files changed
+32
-5
No files matched your search
@@ -280,6 +280,15 @@ def test_s4_status_includes_the_cheap_event_count():
|
||||
assert st.device_time == "2026-10-20T18:07:58"
|
||||
|
||||
|
||||
def test_s4_status_reads_0x49_only_when_asked():
|
||||
# speed: 0x49 is one more round trip, so a plain status never reads it
|
||||
fake = FakeMicromateClient(run_states=[0x01])
|
||||
assert "run_state" not in s4_status(fake, "UM20147").detail
|
||||
assert "read_run_state" not in fake.calls
|
||||
st = s4_status(fake, "UM20147", run_state=True)
|
||||
assert st.detail["run_state"] == {"code": 1, "name": "unknown(0x01)"}
|
||||
|
||||
|
||||
def test_s4_settings_maps_the_decoded_setup():
|
||||
s = s4_settings(FakeMicromateClient(), "UM20147")
|
||||
assert (s.series, s.setup_name, s.record_mode) == (4, "test2.MMB", "Histogram Combo")
|
||||
|
||||
@@ -48,6 +48,14 @@ def test_status_and_settings_with_a_serial(da):
|
||||
assert srv.device_settings(serial="UM20147", **TCP)["record_mode"] == "Histogram Combo"
|
||||
|
||||
|
||||
def test_status_run_state_is_opt_in(da):
|
||||
# called directly, a Query default is truthy: pass it as FastAPI would
|
||||
assert "run_state" not in srv.device_monitor_status(force=False, serial="UM20147", run_state=False,
|
||||
**TCP)["detail"]
|
||||
out = srv.device_monitor_status(force=False, serial="UM20147", run_state=True, **TCP)
|
||||
assert out["detail"]["run_state"] == {"code": 0, "name": "idle"}
|
||||
|
||||
|
||||
def test_hangup(da):
|
||||
srv.device_monitor_status(force=False, serial="UM20147", **TCP)
|
||||
assert srv.device_hangup(**TCP) == {"hung_up": True}
|
||||
|
||||
Reference in new issue
Block a user