From 114cbb4679b3f69f15b2e856fea6b2cef73059bf Mon Sep 17 00:00:00 2001 From: Brian Harrison Date: Wed, 1 Apr 2026 15:39:56 -0400 Subject: [PATCH] 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. --- minimateplus/protocol.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index ad7a921..01c21fd 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -465,7 +465,12 @@ class MiniMateProtocol: ("D", 0x002A, _DATA_PARAMS), # _DATA_PARAMS built above ] - 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: log.debug( @@ -485,10 +490,22 @@ class MiniMateProtocol: continue 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( "read_compliance_config: frame %s page=0x%04X data=%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), ) config.extend(chunk)