diff --git a/aioacaia/acaiascale.py b/aioacaia/acaiascale.py index 62ebf49..53d570e 100644 --- a/aioacaia/acaiascale.py +++ b/aioacaia/acaiascale.py @@ -402,11 +402,15 @@ async def on_bluetooth_data_received( ): data = self._last_short_msg + data self._last_short_msg = None + _LOGGER.debug("Restored message from previous data: %s", data) try: msg = decode(data)[0] except AcaiaMessageTooShort as ex: - self._last_short_msg = ex.bytes_recvd + if 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 return if isinstance(msg, Settings): diff --git a/aioacaia/decode.py b/aioacaia/decode.py index 4eece52..6cd836e 100644 --- a/aioacaia/decode.py +++ b/aioacaia/decode.py @@ -161,7 +161,6 @@ def decode(byte_msg: bytearray): break if msg_start < 0 or len(byte_msg) - msg_start < 6: - _LOGGER.debug("Message too short %s", byte_msg) raise AcaiaMessageTooShort(byte_msg) msg_end = msg_start + byte_msg[msg_start + 3] + 5 diff --git a/run.py b/run.py index 7bc6da0..b0f7d87 100644 --- a/run.py +++ b/run.py @@ -6,6 +6,7 @@ async def main(): + # settings, arr = decode(bytearray(b"\xef\xdd\x08\t]\x02\x02\x01\x00\x01\x01\x00\r`")) scale = AcaiaScale("aa:bb:cc:dd:ee:ff") await scale.on_bluetooth_data_received(None, bytearray(b"\xef\xdd\x0c")) res = await scale.on_bluetooth_data_received( diff --git a/setup.py b/setup.py index 349124b..5e55be4 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="aioacaia", - version="0.1.5b1", + version="0.1.5", description="An async implementation of PyAcaia", long_description=readme, long_description_content_type="text/markdown",