Skip to content

Commit abda3d8

Browse files
committed
Support bytes() on a UUID
1 parent fb91fcb commit abda3d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_ble/uuid/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def __eq__(self, other):
4949
def __str__(self):
5050
return str(self.bleio_uuid)
5151

52+
def __bytes__(self):
53+
b = bytearray(self.bleio_uuid.size // 8)
54+
self.bleio_uuid.pack_into(b)
55+
return bytes(b)
56+
5257
def pack_into(self, buffer, offset=0):
5358
"""Packs the UUID into the buffer at the given offset."""
5459
self.bleio_uuid.pack_into(buffer, offset=offset)

0 commit comments

Comments
 (0)