From a0d8954e28b5ad5c9017cd9e85c4a37a7cb8d51e Mon Sep 17 00:00:00 2001 From: Al Little Date: Wed, 17 May 2023 08:53:51 +0100 Subject: [PATCH 1/6] Added support for 32bit UUID's added in 4.1 of the Bluetooth specification --- bleak/uuids.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bleak/uuids.py b/bleak/uuids.py index 281975e8..2bea9ac5 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -1157,11 +1157,16 @@ def normalize_uuid_str(uuid: str) -> str: - Converted to lower case. - 16-bit UUIDs are expanded to 128-bit. + BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part B - Section 2.5.1 + .. versionadded:: 0.20.0 """ if len(uuid) == 4: # Bluetooth SIG registered 16-bit UUIDs uuid = f"0000{uuid}-0000-1000-8000-00805f9b34fb" + elif len(uuid) == 8: + # Bluetooth SIG registered 32-bit UUIDs + uuid = f"{uuid}-0000-1000-8000-00805f9b34fb" # let UUID class do the validation and conversion to lower case return str(UUID(uuid)) From f6c2a2bd1261475a59e723356876e89fd6421736 Mon Sep 17 00:00:00 2001 From: Al Little Date: Wed, 17 May 2023 15:15:40 +0100 Subject: [PATCH 2/6] Accepted comments Co-authored-by: David Lechner --- bleak/uuids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bleak/uuids.py b/bleak/uuids.py index 2bea9ac5..b58337ba 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -1155,7 +1155,7 @@ def normalize_uuid_str(uuid: str) -> str: Normaizes a UUID to the format used by Bleak. - Converted to lower case. - - 16-bit UUIDs are expanded to 128-bit. + - 16-bit and 32-bit UUIDs are expanded to 128-bit. BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part B - Section 2.5.1 From 507b00f17d3e1bdaa322dbf5adf6ec1d29660d64 Mon Sep 17 00:00:00 2001 From: Al Little Date: Wed, 17 May 2023 15:16:15 +0100 Subject: [PATCH 3/6] Accept comment Co-authored-by: David Lechner --- bleak/uuids.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bleak/uuids.py b/bleak/uuids.py index b58337ba..6574a164 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -1160,6 +1160,8 @@ def normalize_uuid_str(uuid: str) -> str: BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part B - Section 2.5.1 .. versionadded:: 0.20.0 + .. versionchanged:: 0.21.0 + Added support for 32-bit UUIDs. """ if len(uuid) == 4: # Bluetooth SIG registered 16-bit UUIDs From 8204742e272a3d094f2d6d9db8cb8eea76391038 Mon Sep 17 00:00:00 2001 From: Al Little Date: Thu, 25 May 2023 10:05:10 +0100 Subject: [PATCH 4/6] Added test to check longer UUID's --- tests/test_uuid.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_uuid.py b/tests/test_uuid.py index ab97edda..c306f040 100644 --- a/tests/test_uuid.py +++ b/tests/test_uuid.py @@ -3,6 +3,7 @@ def test_uuid_length_normalization(): assert normalize_uuid_str("1801") == "00001801-0000-1000-8000-00805f9b34fb" + assert normalize_uuid_str("DAF51C01") == "daf51c01-0000-1000-8000-00805f9b34fb" def test_uuid_case_normalization(): From 27f3dbc8e07a157191f48d202db890e9fe50d2dd Mon Sep 17 00:00:00 2001 From: Al Little Date: Tue, 13 Jun 2023 15:41:05 +0100 Subject: [PATCH 5/6] Added support for 32bit UUIDs --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 62262e04..20120dce 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ Changed Fixed ----- - Fix handling all access denied errors when enumerating characteristics on Windows. Fixes #1291. +- Added support for 32bit UUIDs. Fixes #1314 `0.20.2`_ (2023-04-19) ====================== From 8b513b791c2766fd0b4525b257caf0130c1719d2 Mon Sep 17 00:00:00 2001 From: Al Little Date: Tue, 13 Jun 2023 15:43:05 +0100 Subject: [PATCH 6/6] Corrected the documentation to conform to project standards --- bleak/uuids.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bleak/uuids.py b/bleak/uuids.py index 6574a164..0ea79d44 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -1157,12 +1157,11 @@ def normalize_uuid_str(uuid: str) -> str: - Converted to lower case. - 16-bit and 32-bit UUIDs are expanded to 128-bit. - BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part B - Section 2.5.1 - .. versionadded:: 0.20.0 .. versionchanged:: 0.21.0 Added support for 32-bit UUIDs. """ + # See: BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part B - Section 2.5.1 if len(uuid) == 4: # Bluetooth SIG registered 16-bit UUIDs uuid = f"0000{uuid}-0000-1000-8000-00805f9b34fb"