protocol: skip duplicate E5 chunks in read_compliance_config

BE11529 sometimes returns frame D with page_key=0x0000 (44 bytes),
identical to the frame B response, inflating cfg to ~1115 bytes and
mis-aligning all field offsets.  Track (page_key, chunk_size) pairs
and drop any repeat before appending to the running config buffer.
This commit is contained in:
Brian Harrison
2026-04-01 15:39:56 -04:00
parent 58a5f15ed5
commit 114cbb4679

View File

@@ -466,6 +466,11 @@ class MiniMateProtocol:
] ]
config = bytearray() config = bytearray()
# Track (page_key, chunk_size) pairs to detect when frame D returns the
# same page/size as frame B — observed on BE11529 when the device is
# busy or connection state is fresh. Duplicate chunks inflate the cfg
# and mis-align field offsets, so we drop them.
seen_chunks: set[tuple[int, int]] = set()
for step_name, step_offset, step_params in _STEPS: for step_name, step_offset, step_params in _STEPS:
log.debug( log.debug(
@@ -485,10 +490,22 @@ class MiniMateProtocol:
continue continue
chunk = data_rsp.data[11:] chunk = data_rsp.data[11:]
page = data_rsp.page_key
key = (page, len(chunk))
if key in seen_chunks:
log.warning(
"read_compliance_config: frame %s page=0x%04X data=%d "
"cfg_chunk=%d DUPLICATE — skipping",
step_name, page, len(data_rsp.data), len(chunk),
)
continue
seen_chunks.add(key)
log.warning( log.warning(
"read_compliance_config: frame %s page=0x%04X data=%d " "read_compliance_config: frame %s page=0x%04X data=%d "
"cfg_chunk=%d running_total=%d", "cfg_chunk=%d running_total=%d",
step_name, data_rsp.page_key, len(data_rsp.data), step_name, page, len(data_rsp.data),
len(chunk), len(config) + len(chunk), len(chunk), len(config) + len(chunk),
) )
config.extend(chunk) config.extend(chunk)