Skip to content

Commit e521e68

Browse files
GATT server support for Rust
With a whole lot of support to get there: - Device::add_service(), with some complexity around how to represent the mutable Python `Service` being used under the covers - AttributePermission, CharacteristicProperty, and other supporting GATT-related stuff - Ability to handle the different data types used by various Python `Characteristic` subclasses - Support for running tests in the context of a background `rootcanal` process - `TryToPy` and `TryFromPy` traits to help make the lifecycle more clear for structs that have a Python equivalent, but are also meaningful standalone - Add example with a minimal battery service - Rearrange known service IDs to make it possible to refer to a service UUID in a meaningful way - Make Address hold its own state to avoid propagating PyResult so much, and adopt the new TryToPy and TryFromPy traits - `AdvertisingDataValue` trait so users don't have to remember as many ADU encoding details at a call site - Sprinkle in more wrap_python_async to work on Python 3.8 and 3.9
1 parent 69c6643 commit e521e68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4043
-1133
lines changed

bumble/device.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from pyee import EventEmitter
4545

4646
from .colors import color
47-
from .att import ATT_CID, ATT_DEFAULT_MTU, ATT_PDU
47+
from .att import ATT_CID, ATT_DEFAULT_MTU, ATT_PDU, Attribute
4848
from .gatt import Characteristic, Descriptor, Service
4949
from .hci import (
5050
HCI_AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P_192_TYPE,
@@ -3533,7 +3533,12 @@ def add_default_services(self, generic_access_service=True):
35333533
async def notify_subscriber(self, connection, attribute, value=None, force=False):
35343534
await self.gatt_server.notify_subscriber(connection, attribute, value, force)
35353535

3536-
async def notify_subscribers(self, attribute, value=None, force=False):
3536+
async def notify_subscribers(
3537+
self,
3538+
attribute: Attribute,
3539+
value: Optional[bytes] = None,
3540+
force: bool = False,
3541+
) -> None:
35373542
await self.gatt_server.notify_subscribers(attribute, value, force)
35383543

35393544
async def indicate_subscriber(self, connection, attribute, value=None, force=False):

bumble/gatt_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ async def notify_subscribers(
491491
attribute: Attribute,
492492
value: Optional[bytes] = None,
493493
force: bool = False,
494-
):
494+
) -> None:
495495
return await self.notify_or_indicate_subscribers(False, attribute, value, force)
496496

497497
async def indicate_subscribers(

0 commit comments

Comments
 (0)