From 79a5e953bce9edb5869e6e4728e821ee908a21d6 Mon Sep 17 00:00:00 2001 From: Gilles Boccon-Gibod Date: Sat, 13 Jan 2024 20:07:58 -0800 Subject: [PATCH] comply with limits for certain advertising event types --- bumble/device.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bumble/device.py b/bumble/device.py index d393f6a9..fd1974c1 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -244,6 +244,9 @@ DEVICE_DEFAULT_ADVERTISING_TX_POWER = ( # fmt: on # pylint: enable=line-too-long +# As specified in 7.8.56 LE Set Extended Advertising Enable command +DEVICE_MAX_HIGH_DUTY_CYCLE_CONNECTABLE_DIRECTED_ADVERTISING_DURATION = 1.28 + # ----------------------------------------------------------------------------- # Classes @@ -2174,7 +2177,13 @@ class Device(CompositeEventEmitter): # Try to start the set if requested. if auto_start: try: - await advertising_set.start() + # pylint: disable=line-too-long + duration = ( + DEVICE_MAX_HIGH_DUTY_CYCLE_CONNECTABLE_DIRECTED_ADVERTISING_DURATION + if advertising_parameters.advertising_event_properties.is_high_duty_cycle_directed_connectable + else 0 + ) + await advertising_set.start(duration=duration) except Exception as error: logger.exception(f'failed to start advertising set: {error}') await advertising_set.remove()