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
@@ -62,8 +62,11 @@ class DeviceAccess:
|
||||
def identify(self, address: UnitAddress, serial: str) -> UnitInfo:
|
||||
return self._dispatch(address, serial, self._s3.identify, s4_identify)
|
||||
|
||||
def status(self, address: UnitAddress, serial: str) -> UnitStatus:
|
||||
return self._dispatch(address, serial, self._s3.status, s4_status)
|
||||
def status(self, address: UnitAddress, serial: str, *, run_state: bool = False) -> UnitStatus:
|
||||
"""`run_state` adds Series 4's raw SUB 0x49 code to `detail` (one more
|
||||
round trip); Series 3 has no 0x49 and ignores it."""
|
||||
return self._dispatch(address, serial, self._s3.status,
|
||||
lambda client, s: s4_status(client, s, run_state=run_state))
|
||||
|
||||
def settings(self, address: UnitAddress, serial: str) -> UnitSettings:
|
||||
return self._dispatch(address, serial, self._s3.settings, s4_settings)
|
||||
|
||||
@@ -249,14 +249,18 @@ def s4_identify(client: Any, serial: str) -> UnitInfo:
|
||||
)
|
||||
|
||||
|
||||
def s4_status(client: Any, serial: str) -> UnitStatus:
|
||||
def s4_status(client: Any, serial: str, run_state: bool = False) -> UnitStatus:
|
||||
st = client.get_state()
|
||||
count = client.get_event_count()
|
||||
detail = {}
|
||||
if run_state: # one more round trip, so only when asked (the ring-path bench test)
|
||||
rs = client.read_run_state()
|
||||
detail["run_state"] = {"code": rs.code, "name": rs.name}
|
||||
return UnitStatus(
|
||||
serial=serial, series=4, monitoring=st.monitoring, battery_volts=st.battery_volts,
|
||||
memory_total_bytes=st.memory_total_bytes, memory_free_bytes=st.memory_free_bytes,
|
||||
device_time=st.device_time.isoformat() if st.device_time else None,
|
||||
event_count=count,
|
||||
event_count=count, detail=detail,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user