mirror of
https://github.com/kawasaki/pyscrlink.git
synced 2025-09-05 01:00:23 +02:00
BLESession.matches: Check service adtypes both 16 bits and 128 bits
LEGO Boost communicates with a Scratch extension through Scratch-link. It was reported that bluepy-scratch-link fails to connect to LEGO Boost. LEGO Boost advertises adtype 0x7 "Complete List of 128-bit Service Class UUIDs". However, bluepy-scratch-link checks only adtype 0x3 "Complete List of 16-bit Service Class UUIDs" which is valid for micro:bit. To allow bluepy-scratch-link, check both adtypes 0x7 and 0x3. Introduce constants to note those two adtype values. Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
This commit is contained in:
@@ -109,6 +109,9 @@ class BLESession(Session):
|
||||
CONNECTED = 3
|
||||
DONE = 4
|
||||
|
||||
ADTYPE_COMP_16B = 0x3
|
||||
ADTYPE_COMP_128B = 0x7
|
||||
|
||||
class BLEThread(threading.Thread):
|
||||
"""
|
||||
Separated thread to control notifications to Scratch.
|
||||
@@ -208,9 +211,13 @@ class BLESession(Session):
|
||||
logger.debug(f"sevice to check: {s}")
|
||||
given_uuid = s
|
||||
logger.debug(f"given: {given_uuid}")
|
||||
service_class_uuid = dev.getValueText(0x3)
|
||||
service_class_uuid = dev.getValueText(self.ADTYPE_COMP_128B)
|
||||
logger.debug(f"adtype 128b: {service_class_uuid}")
|
||||
if not service_class_uuid:
|
||||
continue
|
||||
service_class_uuid = dev.getValueText(self.ADTYPE_COMP_16B)
|
||||
logger.debug(f"adtype 16b: {service_class_uuid}")
|
||||
if not service_class_uuid:
|
||||
continue
|
||||
dev_uuid = UUID(service_class_uuid)
|
||||
logger.debug(f"dev: {dev_uuid}")
|
||||
logger.debug(given_uuid == dev_uuid)
|
||||
|
Reference in New Issue
Block a user