Skip to content

Commit

Permalink
Merge pull request #9 from zweckj/fix/one-byte-messages
Browse files Browse the repository at this point in the history
Check for very short messages
  • Loading branch information
zweckj authored Jan 23, 2025
2 parents bc97a8e + 4d95cf3 commit 0e29404
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion aioacaia/acaiascale.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ async def on_bluetooth_data_received(
try:
msg, _ = decode(data)
except AcaiaMessageTooShort as ex:
if ex.bytes_recvd[0] != HEADER1 or ex.bytes_recvd[1] != HEADER2:
if len(ex.bytes_recvd) < 2:
_LOGGER.debug("Received one byte message: %s", ex.bytes_recvd)
elif ex.bytes_recvd[0] != HEADER1 or ex.bytes_recvd[1] != HEADER2:
_LOGGER.debug("Non-header message too short: %s", ex.bytes_recvd)
else:
self._last_short_msg = ex.bytes_recvd
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aioacaia"
version = "0.1.13"
version = "0.1.14"
license = { text = "MIT" }
description = "An async implementation of PyAcaia"
readme = "README.md"
Expand Down

0 comments on commit 0e29404

Please sign in to comment.