From c8e6a9af2dbda106679fb1849f884651db22ad9f Mon Sep 17 00:00:00 2001 From: Markus Piotrowski Date: Thu, 2 May 2024 23:53:45 +0200 Subject: [PATCH] Lift restriction of UUID length in Client. UUIDS of the 'standard pattern' (12345678-0000-1000-8000-00805f9b34fb) can be supplied as 16 or 32 bit 'short version' (written as string) --- bleekWare/Client.py | 5 +++++ bleekWare/Scanner.py | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bleekWare/Client.py b/bleekWare/Client.py index 1bc37bb..02d0dff 100644 --- a/bleekWare/Client.py +++ b/bleekWare/Client.py @@ -325,6 +325,11 @@ def address(self): def _find_characteristic(self, uuid): """Find and return characteristic object by UUID. PRIVATE.""" + if len(uuid) == 4: + uuid = f'0000{uuid}-0000-1000-8000-00805f9b34fb' + elif len(uuid) == 8: + uuid = f'{uuid}-0000-1000-8000-00805f9b34fb' + for service in self.services: if uuid in service.characteristics: return service.service.getCharacteristic(UUID.fromString(uuid)) diff --git a/bleekWare/Scanner.py b/bleekWare/Scanner.py index 90784ad..2f7a08d 100644 --- a/bleekWare/Scanner.py +++ b/bleekWare/Scanner.py @@ -9,7 +9,6 @@ from java import jclass, jint, jvoid, Override, static_proxy from java.util import HashMap -# from android.bluetooth.le import BluetoothLeScanner from android.bluetooth.le import ScanCallback, ScanResult, ScanSettings from android.bluetooth import BluetoothAdapter