From 9c429ec75a2776ff3053988f0c0191bda625d5f6 Mon Sep 17 00:00:00 2001 From: Gilles Boccon-Gibod Date: Mon, 17 Oct 2022 09:47:09 -0700 Subject: [PATCH] add phy options --- bumble/device.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bumble/device.py b/bumble/device.py index b91bf2b9..de2b7749 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -242,6 +242,20 @@ class AdvertisingType(IntEnum): } +# ----------------------------------------------------------------------------- +class LePhyOptions: + # Coded PHY preference + ANY_CODED_PHY = 0 + PREFER_S_2_CODED_PHY = 1 + PREFER_S_8_CODED_PHY = 2 + + def __init__(self, coded_phy_preference=0): + self.coded_phy_preference = coded_phy_preference + + def __int__(self): + return self.coded_phy_preference & 3 + + # ----------------------------------------------------------------------------- class Peer: def __init__(self, connection): @@ -891,7 +905,6 @@ class Device(CompositeEventEmitter): # Set the advertising parameters await self.send_command(HCI_LE_Set_Advertising_Parameters_Command( - # TODO: use real values, not fixed ones advertising_interval_min = self.advertising_interval_min, advertising_interval_max = self.advertising_interval_max, advertising_type = int(advertising_type), @@ -1349,8 +1362,8 @@ class Device(CompositeEventEmitter): all_phys = all_phys_bits, tx_phys = phy_list_to_bits(tx_phys), rx_phys = phy_list_to_bits(rx_phys), - phy_options = 0 # TODO: parse from function argument - ) + phy_options = 0 if phy_options is None else int(phy_options) + ), check_result=True ) async def set_default_phy(self, tx_phys=None, rx_phys=None):