diff --git a/bumble/device.py b/bumble/device.py index 2e890b76..c0e0c1e0 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -166,6 +166,7 @@ class AdvertisementDataAccumulator: self.advertisement = Advertisement.from_advertising_report(report) self.advertisement.data = AdvertisingData.from_bytes(self.data + report.data) self.advertisement.is_connectable = (self.last_event_type == HCI_LE_Advertising_Report_Event.ADV_IND) + self.advertisement.is_scannable = True else: # Unexpected scan response self.advertisement = None @@ -826,9 +827,9 @@ class Device(CompositeEventEmitter): scanning_phys = 1 << HCI_LE_Set_Extended_Scan_Parameters_Command.LE_1M_PHY scanning_phy_count = 1 - # if self.supports_le_feature(HCI_LE_CODED_PHY_LE_SUPPORTED_FEATURE): - # scanning_phys |= 1 << HCI_LE_Set_Extended_Scan_Parameters_Command.LE_CODED_PHY - # scanning_phy_count += 1 + if self.supports_le_feature(HCI_LE_CODED_PHY_LE_SUPPORTED_FEATURE): + scanning_phys |= 1 << HCI_LE_Set_Extended_Scan_Parameters_Command.LE_CODED_PHY + scanning_phy_count += 1 await self.send_command(HCI_LE_Set_Extended_Scan_Parameters_Command( own_address_type = own_address_type, @@ -863,8 +864,8 @@ class Device(CompositeEventEmitter): filter_duplicates = 1 if filter_duplicates else 0 )) - self.scanning = True self.scanning_is_passive = not active + self.scanning = True async def stop_scanning(self): await self.send_command(HCI_LE_Set_Scan_Enable_Command( diff --git a/bumble/hci.py b/bumble/hci.py index 17205749..98406562 100644 --- a/bumble/hci.py +++ b/bumble/hci.py @@ -670,7 +670,7 @@ HCI_LE_CODED_PHY = 3 HCI_LE_PHY_NAMES = { HCI_LE_1M_PHY: 'LE 1M', - HCI_LE_2M_PHY: 'L2 2M', + HCI_LE_2M_PHY: 'LE 2M', HCI_LE_CODED_PHY: 'LE Coded' } @@ -3045,6 +3045,18 @@ class HCI_LE_Set_Data_Length_Command(HCI_Command): ''' +# ----------------------------------------------------------------------------- +@HCI_Command.command(return_parameters_fields=[ + ('status', STATUS_SPEC), + ('suggested_max_tx_octets', 2), + ('suggested_max_tx_time', 2), +]) +class HCI_LE_Read_Suggested_Default_Data_Length_Command(HCI_Command): + ''' + See Bluetooth spec @ 7.8.34 LE Read Suggested Default Data Length Command + ''' + + # ----------------------------------------------------------------------------- @HCI_Command.command([ ('suggested_max_tx_octets', 2), @@ -3491,6 +3503,140 @@ class HCI_LE_Set_Extended_Scan_Enable_Command(HCI_Command): ''' +# ----------------------------------------------------------------------------- +@HCI_Command.command(fields=None) +class HCI_LE_Extended_Create_Connection_Command(HCI_Command): + ''' + See Bluetooth spec @ 7.8.66 LE Extended Create Connection Command + ''' + + LE_1M_PHY = 0x00 + LE_2M_PHY = 0x01 + LE_CODED_PHY = 0x02 + + INITIATING_PHY_NAMES = ['LE_1M_PHY', 'LE_2M_PHY', 'LE_CODED_PHY'] + + @classmethod + def from_parameters(cls, parameters): + initiator_filter_policy = parameters[0] + own_address_type = parameters[1] + peer_address = Address.parse_address_preceded_by_type(parameters, 2)[1] + initiating_phys = parameters[9] + + phy_bits_set = bin(initiating_phys).count('1') + + def read_parameter_list(offset): + return [struct.unpack_from('