Skip to content

Commit

Permalink
fix: corrected ParseServiceData data length check (#18572)
Browse files Browse the repository at this point in the history
The ParseServiceData function was broken. The length check was utilizing a length of 7 which caused the function to always return None. The correct length of the data parameter is 8. I have made this a constant at the top of the file to also remove the use of a magic number.
  • Loading branch information
jpagecharter authored and pull[bot] committed Oct 31, 2023
1 parent 42177e2 commit 1549102
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/controller/python/chip/ChipBleUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

FAKE_CONN_OBJ_VALUE = 12121212

# Number of bytes in service data payload
SERVICE_DATA_LEN = 8


def VoidPtrToUUIDString(ptr, len):
try:
Expand Down Expand Up @@ -365,7 +368,7 @@ def __init__(self, pairingState, discriminator, vendorId, productId):


def ParseServiceData(data):
if len(data) != 7:
if len(data) != SERVICE_DATA_LEN:
return None
return BleDeviceIdentificationInfo(
int(data[0]),
Expand Down

0 comments on commit 1549102

Please sign in to comment.