protocol: add read_event_index() for SUB 08/F7

Two-step probe+fetch for SUB 08 (EVENT_INDEX), returning the raw 88-byte
(0x58) index block.  SUB_EVENT_INDEX and DATA_LENGTHS[0x08]=0x58 were
already registered — this just wires the method that calls them.

Docstring notes the partially-decoded layout (event count at +3 as uint32 BE,
timestamps at +7) pending live device confirmation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Brian Harrison
2026-04-02 01:59:48 -04:00
parent 6a42facf02
commit ce44852383

View File

@@ -240,6 +240,41 @@ class MiniMateProtocol:
# ── Event download API ────────────────────────────────────────────────────
def read_event_index(self) -> bytes:
"""
Send the SUB 08 (EVENT_INDEX) two-step read and return the raw 88-byte
(0x58) index block.
The index block contains:
+0x00 (3 bytes): total index size or record count — purpose partially
decoded; byte [3] may be a high byte of event count.
+0x03 (4 bytes): stored event count as uint32 BE ❓ (inferred from
captures; see §7.4 in protocol reference)
+0x07 onwards: 6-byte event timestamps (see §8), one per event
Caller is responsible for parsing the returned bytes.
Returns:
Raw 88-byte data section (data[11:11+0x58]).
Raises:
ProtocolError: on timeout, bad checksum, or wrong response SUB.
"""
rsp_sub = _expected_rsp_sub(SUB_EVENT_INDEX)
length = DATA_LENGTHS[SUB_EVENT_INDEX] # 0x58
log.debug("read_event_index: 08 probe")
self._send(build_bw_frame(SUB_EVENT_INDEX, 0))
self._recv_one(expected_sub=rsp_sub)
log.debug("read_event_index: 08 data request offset=0x%02X", length)
self._send(build_bw_frame(SUB_EVENT_INDEX, length))
data_rsp = self._recv_one(expected_sub=rsp_sub)
raw = data_rsp.data[11 : 11 + length]
log.debug("read_event_index: got %d bytes", len(raw))
return raw
def read_event_first(self) -> tuple[bytes, bytes]:
"""
Send the SUB 1E (EVENT_HEADER) two-step read and return the first