fix(sfm): a stale Series-3 id is refused before the full download, not after
Series3Adapter.download_event compared the timestamp only after
download_event_by_key had run the whole 5A. A stale id cost a full
download of the wrong event (minutes on cellular), could surface the
64 KB-page 502 instead of 409, and a lost 0C reply was reported as "the
unit was erased".
- get_events() gains only_key_timestamp: with only_key, if the target's 0C
says another time (or none), the target takes the existing bypass --
no 1F(arm), no POLL, no 5A. A new branch only; it adds no command.
- download_event_by_key(key4, *, expected_timestamp=None) passes it on.
- The adapter converts the id's stamp to that ISO form and checks, in
order: no event -> 404; no readable 0C timestamp -> 502 MalformedReply
("could not read ... record (0C)"); a different time -> 409 StaleEvent;
no frames -> 502.
- The fake's download mirrors the real walk (no frames on a mismatch) and
records what it was asked for.
- Legacy get_events() (none of the new options) is pinned by a test of
its exact call sequence and 5A arguments, written before the change.
Read-only; nothing new on the wire. No codec, store or DB change.
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
157fcc51a7
commit
01b9188f25
5 files changed
+141
-12
No files matched your search
@@ -57,6 +57,15 @@ def s3_event(index, key_hex, when, *, record_type="Waveform", pvs=0.12, frames=T
|
||||
return ev
|
||||
|
||||
|
||||
def _iso(ev):
|
||||
"""minimateplus.client._event_timestamp_iso's format; "" with no timestamp."""
|
||||
ts = ev.timestamp
|
||||
if ts is None:
|
||||
return ""
|
||||
return datetime.datetime(ts.year, ts.month, ts.day, ts.hour or 0, ts.minute or 0,
|
||||
ts.second or 0).isoformat()
|
||||
|
||||
|
||||
def default_s3_events():
|
||||
return [
|
||||
s3_event(0, "01110000", datetime.datetime(2026, 10, 1, 8, 0, 0)),
|
||||
@@ -78,6 +87,8 @@ class FakeMiniMateClient(_Base):
|
||||
)
|
||||
self.compliance = compliance
|
||||
self.events = default_s3_events() if events is None else events
|
||||
self.download_requests: list = [] # (key4, expected_timestamp) per download
|
||||
self.last_download = None
|
||||
|
||||
def connect(self) -> DeviceInfo:
|
||||
self._step("connect")
|
||||
@@ -107,10 +118,18 @@ class FakeMiniMateClient(_Base):
|
||||
out.append(h)
|
||||
return out
|
||||
|
||||
def download_event_by_key(self, key4):
|
||||
def download_event_by_key(self, key4, *, expected_timestamp=None):
|
||||
"""As the real walk: an event whose 0C time is not the expected one comes
|
||||
back without its 5A."""
|
||||
self._step("download_event_by_key")
|
||||
self.download_requests.append((key4, expected_timestamp))
|
||||
self.last_download = None
|
||||
for ev in self.events:
|
||||
if ev._waveform_key == key4:
|
||||
if expected_timestamp is not None and _iso(ev) != expected_timestamp:
|
||||
ev = copy.copy(ev)
|
||||
ev._a5_frames = None
|
||||
self.last_download = ev
|
||||
return ev
|
||||
return None
|
||||
|
||||
|
||||
Reference in new issue
Block a user