fix(minimateplus): the 0x1C status reads a histogram run as monitoring, and unescapes before counting from the end

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
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-26 18:53:11 -04:00
1 parent 8acb9512a9
commit d990466407
5 files changed
+114 -16

No files matched your search

+15 -2
View File
@@ -34,7 +34,7 @@ import re
import struct
from typing import Optional
from .framing import S3Frame
from .framing import S3Frame, unescape_reply
from .models import (
CallHomeConfig,
ComplianceConfig,
@@ -60,6 +60,11 @@ from .transport import SerialTransport, BaseTransport
log = logging.getLogger(__name__)
# SUB 0x1C state-flag values measured while a unit was monitoring: 0x10 (BE11529,
# 2026-04-08, 98 frames) and 0x0B (BE9441 recording a histogram, 2026-10-26).
# Idle is 0x00 on both.
S3_MONITORING_FLAGS = frozenset({0x10, 0x0B})
# ── Module-level constants ────────────────────────────────────────────────────
# Trigger config payload hardcoded from 3-11-26 BW TX capture (BW frame 108).
@@ -2682,6 +2687,10 @@ def _decode_monitor_status(data: bytes) -> MonitorStatus:
mem_total 0x000EFFF2 = 983026 bytes ≈ 960 KB
mem_free 0x000E9E52 = 958034 bytes ≈ 935 KB
"""
# Unescape first (2026-10-26): BE9441's free memory 0x000D0E04 arrived as
# `0d 0e 10 04`, and with the parser's kept 10 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.
data = unescape_reply(data)
# The data section starts at offset 11 (after the S3 section header).
section = data[11:] if len(data) > 11 else data
@@ -2694,7 +2703,11 @@ def _decode_monitor_status(data: bytes) -> MonitorStatus:
# Confirmed from byte diff of all 144 0xE3 data frames in 4-8-26/2ndtry capture:
# section[1] = 0x00 in all IDLE frames, 0x10 in all MONITORING frames.
# (section[6] also changes but has non-binary values 0xea/0x07 — device-specific.)
is_monitoring = len(section) > 1 and section[1] == 0x10
#
# 2026-10-26: 0x0B on BE9441 recording a HISTOGRAM (confirmed at the unit);
# 0x00 on the same unit idle. Only measured values count as monitoring --
# sfm.device_access.s3.S3_RUN_STATES refuses any other for a change.
is_monitoring = len(section) > 1 and section[1] in S3_MONITORING_FLAGS
# The same byte, raw -- but only from a real section: for data of 11 bytes
# or fewer, `section` above falls back to the header itself.
state_flag = data[12] if len(data) > 12 else None