Skip to content

Commit

Permalink
Merge pull request #31 from Bluetooth-Devices/numerical-order-fix
Browse files Browse the repository at this point in the history
fix: warning for numerical order object id
  • Loading branch information
Ernst79 authored Nov 19, 2022
2 parents 4aaac11 + b86feaa commit 7404a9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/bthome_ble/bthome_v2_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def decrypt_payload(
) -> dict[str, float] | None:
"""Decrypt payload."""
print("Nonce:", nonce.hex())
print("CryptData:", payload.hex())
print("Mic:", mic.hex())
print("Ciphertext:", payload.hex())
print("MIC:", mic.hex())
cipher = AES.new(key, AES.MODE_CCM, nonce=nonce, mac_len=4)
print()
print("Starting Decryption data")
Expand Down Expand Up @@ -75,7 +75,8 @@ def encrypt_payload(
print("Binkey:", key.hex())
print("Data:", data.hex())
print("Nonce:", nonce.hex())
print("CryptData:", ciphertext.hex(), "Mic:", mic.hex())
print("Ciphertext:", ciphertext.hex())
print("MIC:", mic.hex())
return b"".join([uuid16, sw_version, ciphertext, count_id, mic])


Expand Down
2 changes: 1 addition & 1 deletion src/bthome_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _parse_payload(self, payload: bytes, sw_version: int) -> bool:
else:
# BTHome V2
obj_meas_type = payload[obj_start]
if prev_obj_meas_type < obj_meas_type:
if prev_obj_meas_type > obj_meas_type:
_LOGGER.warning(
"BTHome device is not sending object ids in numerical order (from low to "
"high object id). This can cause issues with your BTHome receiver, "
Expand Down

0 comments on commit 7404a9b

Please sign in to comment.