protocol: tighten compliance config dedup to exact byte content
Old key was (page_key, chunk_len) which would incorrectly drop a second config section that has the same length as the first (e.g. current-config vs event-time-config when settings haven't changed). New key is the full chunk bytes — only truly byte-identical chunks are dropped. Different data that happens to share page_key and length now comes through correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -501,11 +501,7 @@ class MiniMateProtocol:
|
|||||||
]
|
]
|
||||||
|
|
||||||
config = bytearray()
|
config = bytearray()
|
||||||
# Track (page_key, chunk_size) pairs to detect when frame D returns the
|
seen_bytes: set[bytes] = set() # exact-content dedup (not page_key+len)
|
||||||
# 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(
|
||||||
@@ -526,17 +522,16 @@ class MiniMateProtocol:
|
|||||||
|
|
||||||
chunk = data_rsp.data[11:]
|
chunk = data_rsp.data[11:]
|
||||||
page = data_rsp.page_key
|
page = data_rsp.page_key
|
||||||
key = (page, len(chunk))
|
|
||||||
|
|
||||||
if key in seen_chunks:
|
if chunk in seen_bytes:
|
||||||
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 DUPLICATE — skipping",
|
"cfg_chunk=%d BYTE-IDENTICAL DUPLICATE — skipping",
|
||||||
step_name, page, len(data_rsp.data), len(chunk),
|
step_name, page, len(data_rsp.data), len(chunk),
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
seen_chunks.add(key)
|
seen_bytes.add(bytes(chunk))
|
||||||
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",
|
||||||
|
|||||||
Reference in New Issue
Block a user