Unescape each 1A data frame, take data[11:], drop the one non-content
byte that starts every frame but the last: 2,090 bytes headed by
N = 2090, Series IV's 0x1A layout. Measured on BE9441's 10-26
recording (12 reads, both frame patterns); the read after each
Blastware write equals the image written. read_compliance_content is
strict (a missing frame raises) and unjudged (a monitoring unit's
device-info answer comes back for the caller to recognise).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
call_home_image returns the unescaped N + 2 image, but the send path handed it
to write_call_home_config, whose write_image unescapes again -- and unescaping
is not idempotent: a real 0x10 before 02/03/04 loses its 0x10. A call-in time
of 16:02-16:04 (hour 0x10) is exactly that. One such time made the send refuse
before the wire yet audited as 'sent, acknowledgement lost'; two made it send a
block shifted by two bytes from [101] (num_retries and the time fields wrong).
The Blastware-frame test could not see it: it checked the image builder, not
the bytes the protocol framed.
- MiniMateProtocol.write_call_home_image(image) frames a built image once
(0x7E, ack 0x81, 0x7F, ack 0x80), raising ImageRefused before any byte when
it is not a whole block; write_call_home_config (the legacy multi-field path)
is write_image once + that. Its stale 127-byte docstring is gone.
- MiniMateClient.write_call_home_image uses it.
- The Series-3 change passes is_refusal=ImageRefused, so a pre-wire refusal is
audited as nothing sent (sent = 0), not as a lost ack.
Tests drive the real client -> protocol over a stub answering with BE11529's
recorded acks: the unit's own read, a 16:02 time, and 16:03 + 16:04 all go out
exactly as built; a short image is refused with nothing written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
- minimateplus.protocol: call_home_enabled(raw) reads byte 5 of the UNESCAPED
0x2C payload (0x01 on / 0x00 off, measured 2026-04-20; anything else None --
bench finding #1's lesson: an escaped byte before it would move the raw
index); call_home_image(raw, enabled) is write_image's N + 2 image with byte 5
set and everything else as read, refusing a byte 5 never measured.
- MiniMateClient.read_call_home_raw() / write_call_home_image(image) (0x7E then
0x7F, each ack checked, never retried).
- Series3Adapter.call_home_state (wake, then 0x2C; no serial read, like status)
and change_call_home: the shared change core with a connect() identity check,
state 'enabled' / 'disabled' / 'unknown(0xNN)' (unknown sends nothing), the
plan showing both exact frames, a snapshot of both unescaped images.
- S3_CALL_HOME_FRAME_VERIFIED = False: a live change is refused (501) before any
connection until the frame is reproduced from Blastware's (next commit).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
_encode_compliance_config patches the raw SUB 1A bytes at offsets measured at
1024 sps (April 2026), where the escape before 04 sits between the mode and the
anchor. b320a53 moved the decoder to the measured layout (unescaped: mode -7,
rate -6, interval -4, record time +6), which exposed the encoder: on BE9441's
recorded 10-25 Continuous / 4096 block a mode change rewrote the byte in front
of the mode, and on the 10-26 Histogram+Continuous / 2048 block a sample-rate
change landed one byte off. The old decoder read the same wrong bytes, so such
a write looked as if it had taken.
The encoder now decodes its own result with the decoder and raises ValueError
when mode, sample rate, interval or record time would not read back as asked
(or a field not asked for would change) -- before push_config_raw sends a byte.
No write offset is moved: rewriting the encoder on unescaped bytes is #46's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
The unit escapes 02/03/04/10 in every reply and S3FrameParser keeps the 10 of
10 02/03/04, so on the raw SUB 1A bytes an escaped mode, rate or interval
shifted every field after it: BE9441 at Histogram / 4096 sps / 2 s read back as
0 sps and a 4098 s interval (bench 2026-10-29), and a Continuous unit read as
Single Shot. The four anchor fields are now read from unescape_reply(data):
mode anchor-7, sample rate anchor-6, interval anchor-4, record time anchor+6 --
measured on all four distinct recorded replies, two of them Blastware's own
writes (15 min, then 2 s). The old 'anchor-7 = constant 0x10' was the escape
before 04 at 1024 sps.
The channel block and strings still read the raw bytes: their label offsets were
measured there and are wrong unescaped (pinned by a test). A reply with no
anchor -- BE9441's monitoring-time 1A answer was its device-info block -- leaves
all four None.
Store consequence: none; this is the live settings read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
0xA2 is CONFIRM ERASE on a MiniMate and ends a call-home on a Micromate, and the
legacy host/port routes had no identity check: only the MiniMate parser's
inability to read a Micromate's replies stood between Diagnostics' Erase and a
Micromate (phase 1c safeguard, agreed with Brian 2026-10-28).
_require_series3(unit_serial, expected) refuses (409, 'nothing sent') unless the
unit's own serial is Series 3 and, when ?serial= names one, that one:
- POST /device/config (+ /config/project) and /device/events/erase: the serial
connect() already reads -- no extra request;
- /device/rescue (when it writes call-home or erases) and POST /device/call_home:
one SUB 0x15 read (new MiniMateClient.read_serial).
Exempt, with the reason in a comment: legacy monitor start/stop, blind stop, slow
drip, spam -- 0x96/0x97 mean the same on both series (measured), and the rescue
tools must reach a unit too wedged to answer.
Tests: each guarded route refuses a unit answering UM20147 and a different BE
unit with no write call, proceeds for the named unit (normalised), reuses
connect()'s serial where it has one; the blind stop builds no client;
read_serial decodes BE9441's recorded 0x15 reply.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Review of b5037b0 (measured on 12 recorded SFM compliance reads): the read
keeps three escape bytes from its reply headers, so every real config image is
refused by write_image -- correctly, but only after 68 and 73 had been sent,
with a message saying nothing was. All four blocks are now checked first; the
test feeds the block exactly as SFM's read produces it and asserts no frame is
sent (two went out without the check).
Config push stays unusable on purpose: fixing that read alone would let the
compliance encoder write some fields to the wrong bytes (e.g. 4,096 sps as
4,112) while the image still passes. The rework -- logical read, encoding at
measured offsets with #48, a diff check, N pinned per SUB, an idle check, the
start/stop safeguards on POST /device/config -- is recorded in the spec and on
#46. Start/stop frames are unchanged (verified byte-identical by the review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Measured against every Blastware request on record: the uploaded Feb-Apr 2026
captures (3,869 frames, 3,869 re-encode exactly) and BE9441's two sends on
2026-10-26 (26 write frames). A write is the standard 16-byte request plus its
data, every 02/03/04/10 escaped, SUM8 checksum; the length field is the data's
length. A config block starts with its own length N and is written as N + 2
bytes: event index (68) and trigger (82) as read plus 02 00 / 00 00 (constant on
15 sends), waveform data (69) and the 2,092-byte compliance image (71) whole.
The compliance image goes in addressed chunks (params[2:4] = address): 512 bytes
tonight (Blastware 10.74), 1,024 in March.
- framing.build_bw_write_frame: uniform escaping, SUM8, length = len(data).
RETRACTED: 'only BW_CMD doubled', the 'DLE-aware checksum', 'offset = data[1]
+ 2' -- fitted to frames still holding their escape bytes ('data 91, offset 90'
was 90 bytes and one escape). It got 7 of every 13 frames in a write wrong.
- protocol.write_image(): unescapes (callers may pass the parser's form), adds
the trailing two bytes to an N-byte block, and REFUSES anything else before a
byte is sent -- an edit beside a kept escape byte (the old encoder's anc-9
hazard) leaves an image one byte long.
- write_compliance_config_raw: 512-byte addressed chunks, then confirm 72.
- read_event_index / read_waveform_data_raw unescape before slicing (a block
holding 02/03/04/10 came out short); new read_trigger_config (SUB 0x2E).
- apply_config reads the unit's trigger block. RETRACTED: the block
'hardcoded from 3-11-26 -- no read exists'. Blastware reads it; byte 5 has
been 01 / 03 / 04 by unit and session, and the March copy (03) would have
changed BE9441's (01).
- The call-home write (7E) goes through write_image: its 127-byte 'read + 00 00'
is the 126-byte image (N = 0x7C). No Blastware 7E is on record here -- that
one is inferred from the other 77 write frames.
Tests: tonight's 26 and every Feb-Apr write frame rebuilt byte for byte; each
block as read written exactly as Blastware wrote it; the parser's form; the
stray-byte refusal; the reads against the unit's recorded replies; apply_config
writes BE9441's own trigger block. Six mutants, each caught. The old
test_write_frames.py (25 tests that had been skipping) runs now that the
captures are here, rewritten to the measured model.
Not yet sent to a unit: a config push changes settings, so its first live use
is a bench session with Brian. No codec, store or DB change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Second start through SFM, BE9441 2026-10-26 23:54:41: acked 0x69, and Brian saw
'starting, performing sensor check, recording' -- but the read-back's single
SESSION_RESET + POLL went out 2.3 s after the ack, inside the ~30 s sensor
check, and was never answered or re-sent (504 after 120 s, audit ca7b5b42).
Brian: every unit is set to sensor-check before monitoring, ~30 s, then
'Recording...'.
- MiniMateProtocol.wake(attempt_s, deadline_s): SESSION_RESET + POLL re-sent
every attempt_s until the unit answers, then the POLL data step; a named
timeout at the deadline. Reads only. MiniMateClient.wake() wraps it.
- The Series-3 change: after a START, the first read waits S3_SENSOR_CHECK_S
(30 s) before asking; every read then wakes with retries (every 5 s, up to
60 s). A stop is unchanged -- its read-back was confirmed three times tonight.
Tests: a unit deaf for 4 probes is asked a 5th time and answers; a unit that
never answers ends in the named timeout after ~6 probes; a start's first read
waits the sensor check, a stop's does not; every read is preceded by a wake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Measured on BE9441 tonight, through the recording bridge:
- Monitoring flag 0x0B while recording a histogram (confirmed at the unit), 0x00
idle. Only 0x10 had been measured as monitoring (BE11529, 2026-04-08), so the
status showed 'not monitoring' and the change path refused the state as
unknown(0x0B) -- refused, not skipped, which is the design working. 0x0B joins
S3_RUN_STATES and S3_MONITORING_FLAGS as measured. The shared status's
'monitoring' now follows the change path's reading: None for an unmeasured
flag, never a guessed False.
- Free memory 0x000D0E04 arrived as 0d 0e 10 04. The parser keeps the 10 of a
10 02/03/04 escape, so every field counted from the end read one byte off:
419.84 V and 251,655,168 bytes for 6.76 V and 983,028. New
framing.unescape_reply() (also used by parse_strt_end_key) runs first.
Tests: the two recorded replies (idle 16:24, monitoring 18:47) decode to the
unit's own values; each escaped value in the last ten bytes decodes; the status
mapping for 00 / 10 / 0B / unmeasured. No codec, store or DB change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
BE9441 rebooted mid-download at the bench (2026-10-25): the chunk at 0x7D06
got one stray byte and then silence, the 5A loop logged "unexpected end-of-
stream -- proceeding to TERM", the TERM got no reply either, and the short event
(17,920 / 17,920 / 17,408 of 21,504 samples) was stored as a success.
read_bulk_waveform_stream(strict=True) now raises on every early end: no STRT,
a metadata page or chunk with no reply, a mid-stream terminator, the chunk cap,
or no TERM reply. get_events passes it for the strict walks (headers_only,
only_key) and, in strict mode, re-raises a 5A error instead of logging
"metadata unavailable" and returning the event without frames. The legacy
full walk is unchanged, call for call (strict passed only when on).
Tests replay BE9441's recorded session through the real MiniMateClient: whole,
event 1 comes back in full; with the 5A stream quiet from chunk 40 while the
walk is still answered -- the bench's reboot -- it raises "ended early".
No codec, store or DB change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
BE9441 (MiniMate bench, 2026-10-25) answers b"BE9441\x00?": six characters,
the terminator, a leftover byte. rstrip(b"\x00") kept the "?", so the serial
read "BE9441\x00?" and the serial-named path refused every request as the wrong
unit (409). Seven-character serials fill the field to the terminator, which is
why no earlier unit showed it. The legacy /device/info output is cleaned too.
No codec, store or DB change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Final fix wave for phase 3 (start/stop monitoring), per the whole-phase review.
- I1 + M2: every failure after the send has started is a ChangeUnconfirmed
(audit_id, sent = "acknowledged" | "unknown", the cause's HTTP status) whose
message says the frame was sent and names the audit record -- the ring in
place of the ack, the four lost-ack follow-ups, and the three read-back
paths. Series4Session releases the line on it. Every audit finish goes
through one helper; a finish that fails is AuditIncomplete (500) and still
says what happened to the unit. The line is kept.
- I2: device_commands gains `sent` (1 acknowledged, 0 nothing sent, NULL
unknown) and `states` (before / seen / after), with an idempotent ADD COLUMN
in _migrate for a table created earlier on this branch.
- M1: a RADIO RING already buffered is caught before 0x96/0x97 goes out
(pre_send = read_unsolicited, one 10 ms transport read). That is a
CallHomeInProgress with sent=0, not ChangeUnconfirmed.
- M3: Series 3 reads the raw 0x1C flag (new MonitorStatus.state_flag); a byte
other than 0x00/0x10, or a short section, is unknown(...) and refused.
- M8: even_if_already on a unit already in the state notes that the read-back
proves nothing.
- M10: a scan pins `.protocol.execute(` to sfm/device_access/s4.py; both
scans fail closed on a file that does not parse.
- M11: docs corrected (CLAUDE.md phase-2 sentence, phase-3 bullet, REST list;
micromate/protocol.py scope and the 0x49 read_state docstring; s4.py; route
docstrings). "No command has ever been originated" is NOT retracted.
- M12: GET /db/device_commands normalises the serial.
- Minors: unused imports, S3 dry-run frames and 120 s timeout pinned, test
rename, serial-cache and short-0x49 tests, _RUN_STATES comment.
Schema: two NULLable columns on the branch-new device_commands table, added
by _migrate on open; no backfill. No codec change, TOOL_VERSION unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
One lost 1F reply made the list return 1 of 3 events as a 200, and on a
download gave a false 404. The list also ran on the 120 s download
timeout, so each lost reply stalled the walk 120 s with the unit locked.
- get_events() strict mode (headers_only, or only_key): a lost 0A reply,
a lost 1F(browse) reply on the success path and on the partial-record
path all re-raise their ProtocolError; a 1F that hands back a key
already walked raises ProtocolError("event chain did not advance ...").
Legacy calls (none of the new options) behave exactly as before --
pinned by tests of the same three faults under get_events().
- Series3Adapter.list_events runs on the default timeout (10 s on TCP);
download_event keeps 120 s.
- FakeProto gains optional lost-reply injection; its default is unchanged.
The repeat-key guard sits at the loop head, which is reached only for a
non-null key -- equivalent to checking each 1F's key, in one place.
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
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
list_event_headers() walks every event's 0A/1E/0C/1F without starting a 5A.
download_event_by_key() downloads one event in full and walks past the others
without their 5A, stopping once it has it. Both ride two new keyword options on
get_events() (headers_only, only_key); the default path is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
The BW filename encodes only the serial NUMBER — `<letter><3 digits>`, so
`L895…` is 10895 and nothing more. The two-letter family prefix is not in it:
"BE" is a MiniMate Plus, "BA" a BlastMate. Both are Series III and their
files are byte-identical in every way that matters — all 1,493 BlastMate
binaries in the DL2 archive decode through the existing codec at 100%, same
four channels — so the serial string was the only thing standing between SFM
and BlastMate support.
Two sites synthesised the prefix and got it wrong:
- waveform_store `_serial_from_bw_filename` returned f"BE{num}" on import, so
a BlastMate event was filed under a unit that does not exist, silently, and
Terra-View read it straight through. Split into
`_serial_number_from_bw_filename` (the number, which the filename really
does carry) and a new `_serial_from_bw_bytes` that reads the serial out of
the body and accepts it only when its numeric part agrees with the
filename. save_imported_bw now prefers hint -> body -> filename guess.
Verified against real archive bytes for BA9229, BA10060, BA10895, BA15957
and BE9558/BE11529/BE18003.
- client `_decode_0a_partial_header` searched for a literal b"BE" in the
monitor-log partial record. On a BlastMate that returns -1 and skips the
whole block, so the geo threshold went missing along with the serial. Now
matches any two-letter prefix, and requires the NUL terminator — stricter
than the bare two-byte search it replaces.
Nothing to migrate: no BlastMate events are in prod. The archive's BA units
last recorded 2018-10 (BA9229, BA15957), 2023-08 (BA10895) and 2023-11
(BA10060), and the prod backfill only reaches back to ~May 2025.
21 tests. Suite: 309 passed, same 16 pre-existing failures as at HEAD
(15 missing ASCII fixtures + one peak_values assertion, all untouched here).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgTe8CamXAHcAmaQ6QNcog
Replaces the broken legacy int16 LE decoder in client.py with the
verified multi-channel codec. Three changes:
1. blastware_file.extract_body_bytes(a5_frames) — new helper that
factors out the body-reconstruction logic from write_blastware_file
so both writers (BW binary) and decoders (sample arrays) can use
the same canonical bytes.
2. waveform_codec.decode_a5_frames(a5_frames) — production entry point.
Returns the raw_samples dict consumers expect (Tran/Vert/Long as
int16 ADC counts; MicL as native ADC counts). Internally:
A5 frames → extract_body_bytes → decode_waveform_v2
→ decoded_to_adc_counts (geos ×16; mic pass-through)
3. waveform_codec.mic_count_to_db(count) — MicL ADC → dB(L) per BW's
display formula:
dB = sign(count) × (81.94 + 20 × log10(|count|)) for |count| ≥ 1
Verified against V70 fixture: count=813 → 140.14 dB (BW PSPL 140.1).
client.py:_decode_a5_waveform is reduced to a thin wrapper that calls
decode_a5_frames and populates event.raw_samples. Original implementation
preserved as _decode_a5_waveform_LEGACY (dead code; reference only).
Also fixed a tail-end bug in decode_waveform_v2 where trailer-section
"40 02" markers (containing ASCII serial bytes, NOT real segment headers)
were being mis-interpreted, producing 2 spurious samples per channel at
the end of each event. Added bytes [12:14] == "02 00" validation to
reject non-header markers.
7 new pytest tests cover the new helpers and dB conversion. Total:
71 passing (up from 64).
Known limitation (carried over from before): the walker still stops
mid-event on the loudest fixtures (SP0/SS0/SV0/event-b) at some
mid-segment edge cases not yet characterized. Every sample reached
is decoded correctly; the walker just doesn't reach all of them.
Loud events still yield 5,000–15,000 byte-exact samples each.
### Added
- **Layered event storage architecture.** Each event now lands as four
files in the per-serial waveform store, each with a clear role:
- `<filename>` — the Blastware-readable binary (BW file). Untouched.
- `<filename>.a5.pkl` — the raw 5A frames (regenerative source).
- `<filename>.h5` — clean per-channel waveform arrays in physical
units (in/s for geo, psi for mic) plus event metadata (HDF5 with
gzip compression). This is the canonical format for downstream
analysis tools.
- `<filename>.sfm.json` — the modern review/metadata sidecar (peaks,
project, source provenance, review state, extensions).
SQLite (`seismo_relay.db`) is the searchable index over all four.
- **Plot-ready waveform JSON (`sfm.plot.v1`).** The `/device/event/{idx}/waveform`
and `/db/events/{id}/waveform.json` endpoints now return samples in
physical units with explicit time-axis metadata, peak markers, and
per-channel unit hints — no more guessing the ADC-to-velocity scale
client-side. The webapp waveform viewer was rewritten to consume
this shape.
- **In-app waveform viewer accuracy fix.** The standalone SFM webapp
viewer was scaling geophone amplitudes by `geoAdcScale / 32767`
(≈ 6.206 / 32767), where `geoAdcScale = 6.206053` is the device's
*in/s per V* hardware constant — not the ADC-counts-to-velocity
factor. This silently scaled every plot ~38% too low for Normal-range
geophones (the correct full-scale is 10.0 in/s, or 1.25 in/s for
Sensitive). Conversion is now done server-side using the geo_range
from compliance config; the client just plots.
- New `sfm/event_hdf5.py` module: `write_event_hdf5()`,
`read_event_hdf5()`, plus a plot-JSON helper.
- Backfill script extended to also emit `.h5` for existing events.
### Dependencies
- Added `h5py>=3.10` and `numpy>=1.24` for the HDF5 storage layer.
- Added `python-multipart>=0.0.7` (required by FastAPI for the
`/db/import/blastware_file` endpoint introduced in this release).
- Added `waveform_key` and `event_timestamp` columns to `CachedEvent` and `CachedWaveform` for integrity verification.
- Implemented logic to flush the cache when a mismatch in (waveform_key, event_timestamp) is detected during event and waveform updates.
- Enhanced `set_events` and `set_waveform` methods to check for mismatches and trigger cache eviction as necessary.
- Introduced a new `LiveCache` class to manage in-memory caching of live device data, separating it from the server logic for better testability.
- Added tests to verify the correctness of cache invalidation logic, particularly for post-erase key reuse scenarios.
- Updated web application to include a "Force refresh" toggle, allowing users to bypass the cache and re-fetch data from the device.
For 2-second events at 1024 sps the "Project:" metadata frame appears
beyond chunk 32 (the old default cap), causing the safety limit to be
hit and ~34 KB of waveform data to be downloaded instead of stopping
at the metadata frame. Raising max_chunks to 128 ensures
stop_after_metadata=True can locate the metadata frame for record
times up to ~4 seconds.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Added `CallHomeConfig` model to represent the Auto Call Home settings.
- Introduced methods in `MiniMateClient` for reading (`get_call_home_config`) and writing (`set_call_home_config`) the call home configuration.
- Updated `MiniMateProtocol` with new commands for call home operations (SUB 0x2C for read, SUB 0x7E for write, and SUB 0x7F for confirm).
- Created API endpoints for retrieving and updating call home settings in the server.
- Enhanced the web interface with a new "Call Home" tab for user interaction with call home settings.
- Implemented JavaScript functions for reading and writing call home configurations from the web app.
Add full decode pipeline for 0x2C partial records from the device's event
list, representing continuous monitoring intervals where no threshold was
crossed. These records appear interleaved with full triggered events in the
browse walk and were previously ignored.
minimateplus/models.py
- Add MonitorLogEntry dataclass: key, start_time, stop_time, serial,
geo_threshold_ips, raw_header, duration_seconds property
minimateplus/protocol.py
- read_waveform_header() now returns (data_rsp.data, length) — full payload
including the record-type byte at position 0 — instead of the sliced header.
Callers that need the old slice use raw_data[11:11+length] as before.
minimateplus/client.py
- Add _decode_0a_partial_header(): auto-detects 9-byte (sub_code=0x10) vs
10-byte (sub_code=0x03) timestamp format, handles 1-byte inter-timestamp
gap, extracts serial via BE anchor and geo threshold via Geo: anchor.
- Add get_monitor_log_entries(skip_keys=None): browse walk (1E → 0A → 1F),
decodes partial records, skips full records and already-seen keys.
minimateplus/__init__.py
- Export MonitorLogEntry
bridges/ach_server.py
- After get_events(), call get_monitor_log_entries(skip_keys=seen_keys) and
save new entries to monitor_log.json in the session directory.
- Add _monitor_log_entry_to_dict() helper.
- Include monitor log keys in downloaded_keys for state persistence.
CLAUDE.md / CHANGELOG.md
- Document 0x2C partial record layout (timestamp format, ASCII metadata
region, 1-byte gap edge case) confirmed from 4-11-26 MITM capture.
- Version bump to v0.10.0; update What's next.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_decode_event_count: read uint16 BE at offset 10 (confirmed 2026-04-10 from
live BE11529 event index — data[10:12]=0x0006=6, matches device LCD).
Previous uint32 at offset 3 always returned 1 regardless of event count.
ach_server.py: use device_info.event_count (already fetched during connect())
instead of calling count_events() separately. This saves 2*N round-trips and
avoids the 1F linked-list walk which was overcounting on some devices.
count_events() kept as fallback when connect() is skipped (--events-only).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace all Unicode arrows/checkmarks (-> [OK] [FAIL]) in ach_server.py
and client.py log calls — Windows cp1252 console can't encode them
- Fix DeviceInfo attribute: serial_number -> serial
- Fix _device_info_to_dict key: serial_number -> serial
- Demote count_events 1E/1F per-key log lines from WARNING to DEBUG
(they were flooding the console on devices with many stored events)
- FileHandler now opens with encoding='utf-8' so session log files
can hold any characters without codec errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ach_server.py:
- Add ach_state.json per-unit state tracking (keyed by serial number)
- count_events() before any download; skip session if no new events since last call-home
- Download only events beyond the previous high-water mark (all_events[last_count:])
- --max-events N safety cap for first-run units with many stored events
- state_path and max_events wired through AchSession constructor and serve()
client.py (_decode_monitor_status):
- Revert monitoring flag to section[1] == 0x10 (was incorrectly changed to section[6])
- Fix battery/memory offsets to section[-10:-8], [-8:-4], [-4:] (no trailing checksum byte)
- Both confirmed by full byte diff of all 144 0xE3 data frames in 4-8-26/2ndtry capture
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
section[6] is the monitoring flag (was wrongly section[1] — section[1] is always
0x00 in both states). Battery and memory fields use relative-from-end offsets
(section[-11:-9], section[-9:-5], section[-5:-1]) instead of absolute positions,
which broke when the payload grew by 3 bytes in monitoring mode.
Confirmed from full byte diff of 142 0xE3 frames in 4-8-26/2ndtry capture.
SFM start_monitoring now polls /device/monitor/status every 5s for up to 60s
instead of a fixed 25s delay (unit runs ~40s on-device sensor check before
confirming monitoring state).
Also corrects stale 1C→6E response anomaly claim in protocol reference — no
exceptions to the 0xFF−SUB rule are known.
- Introduced new SUBs for monitoring status, start, and stop commands in protocol.py.
- Implemented read_monitor_status, start_monitoring, and stop_monitoring methods in MiniMateProtocol class.
- Added new API endpoints for monitoring status retrieval and control in server.py.
- Enhanced the web application with a monitoring panel, including battery and memory status display.
- Created a new Python script to parse SUB 0x1C response frames for monitoring status.
- Documented the monitoring status response format and field locations in markdown and text files.