From 1549102d4f552c862d28d2d5bf9179824742ef01 Mon Sep 17 00:00:00 2001 From: jpagecharter <35784133+jpagecharter@users.noreply.github.com> Date: Wed, 18 May 2022 14:27:14 -0600 Subject: [PATCH] fix: corrected ParseServiceData data length check (#18572) 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. --- src/controller/python/chip/ChipBleUtility.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controller/python/chip/ChipBleUtility.py b/src/controller/python/chip/ChipBleUtility.py index 95abc3b7c8be76..f4d868f29ef775 100644 --- a/src/controller/python/chip/ChipBleUtility.py +++ b/src/controller/python/chip/ChipBleUtility.py @@ -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: @@ -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]),