From 8d0969365414a3ba0628736ce7e773d653ccd005 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Fri, 5 May 2023 17:03:21 +0800 Subject: [PATCH] Implement GATT server included service declaration --- bumble/gatt.py | 39 +++++++++++++++++++++++++++++++++++++-- bumble/gatt_server.py | 12 +++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/bumble/gatt.py b/bumble/gatt.py index 9721fd4..d99df81 100644 --- a/bumble/gatt.py +++ b/bumble/gatt.py @@ -205,8 +205,16 @@ class Service(Attribute): ''' uuid: UUID + characteristics: List[Characteristic] + included_services: List[Service] - def __init__(self, uuid, characteristics: List[Characteristic], primary=True): + def __init__( + self, + uuid, + characteristics: List[Characteristic], + included_services: List[Service] = [], + primary=True, + ): # Convert the uuid to a UUID object if it isn't already if isinstance(uuid, str): uuid = UUID(uuid) @@ -219,7 +227,7 @@ class Service(Attribute): uuid.to_pdu_bytes(), ) self.uuid = uuid - # self.included_services = [] + self.included_services = included_services[:] self.characteristics = characteristics[:] self.primary = primary @@ -253,6 +261,33 @@ class TemplateService(Service): super().__init__(self.UUID, characteristics, primary) +# ----------------------------------------------------------------------------- +class IncludedServiceDeclaration(Attribute): + ''' + See Vol 3, Part G - 3.2 INCLUDE DEFINITION + ''' + + service: Service + + def __init__(self, service): + declaration_bytes = struct.pack( + '