Skip to content

Commit 7a6f7fc

Browse files
committed
preparing to make into recipe
1 parent 486cdf9 commit 7a6f7fc

File tree

8 files changed

+26
-17
lines changed

8 files changed

+26
-17
lines changed

gattlib/uuid.py

Lines changed: 0 additions & 17 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

recipes/gattlib/src/gattlib/uuid.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import re
2+
from uuid import UUID
3+
4+
SDP_UUID16 = 0x19
5+
SDP_UUID32 = 0x1A
6+
SDP_UUID128 = 0x1C
7+
8+
GATT_STANDARD_UUID_FORMAT = re.compile("(\S+)-0000-1000-8000-00805f9b34fb", flags=re.IGNORECASE)
9+
10+
def gattlib_uuid_to_uuid(gattlib_uuid):
11+
return UUID(gattlib_uuid.toString())
12+
13+
def gattlib_uuid_to_int(gattlib_uuid):
14+
return gattlib_uuid_str_to_int(gattlib_uuid.toString())
15+
16+
def gattlib_uuid_str_to_int(uuid_str):
17+
# Check if the string could already encode a UUID16 or UUID32
18+
if len(uuid_str) <= 8:
19+
return int(uuid_str, 16)
20+
21+
# Check if it is a standard UUID or not
22+
match = GATT_STANDARD_UUID_FORMAT.search(uuid_str)
23+
if match:
24+
return int(match.group(1), 16)
25+
else:
26+
return UUID(uuid_str).int

0 commit comments

Comments
 (0)