mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
A BATTERY frame with len(data) < 3 caused dbuf.read(2) to return short bytes; int.from_bytes(b"", ...) silently yielded 0, propagating a bogus level=0 to HA sensors. Same silent-zero class as N07 (storage fields). Option B: early-return with debug log, matching the NEW-C pattern for STATUS_RESPONSE. No BATTERY event is dispatched for malformed frames. Not in the original forensics report — discovered during G1 N07 work and logged in issues_log.md. Resolved here because no later branch touches this handler. Files changed: - src/meshcore/reader.py: add `if len(data) < 3: return` guard before the level read in the BATTERY branch - tests/unit/test_reader.py: add test_g1_battery_too_short_for_level — sends a 1-byte frame (type only), asserts no BATTERY event dispatched and debug log emitted |
||
|---|---|---|
| .. | ||
| commands | ||
| __init__.py | ||
| ble_cx.py | ||
| connection_manager.py | ||
| events.py | ||
| lpp_json_encoder.py | ||
| meshcore.py | ||
| meshcore_parser.py | ||
| packets.py | ||
| parsing.py | ||
| reader.py | ||
| serial_cx.py | ||
| tcp_cx.py | ||