From 31edd58b3d2561c94ea04a4d7fb910d76372fb2e Mon Sep 17 00:00:00 2001 From: Gilles Boccon-Gibod Date: Thu, 4 Aug 2022 19:29:55 -0700 Subject: [PATCH] add extended report class --- bumble/hci.py | 119 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 112 insertions(+), 7 deletions(-) diff --git a/bumble/hci.py b/bumble/hci.py index c8aed197..1400baac 100644 --- a/bumble/hci.py +++ b/bumble/hci.py @@ -3141,8 +3141,8 @@ class HCI_LE_Set_Extended_Scan_Parameters_Command(HCI_Command): LE_1M_PHY = 0x00 LE_CODED_PHY = 0x02 - @staticmethod - def from_parameters(parameters): + @classmethod + def from_parameters(cls, parameters): own_address_type = parameters[0] scanning_filter_policy = parameters[1] scanning_phys = parameters[2] @@ -3156,7 +3156,7 @@ class HCI_LE_Set_Extended_Scan_Parameters_Command(HCI_Command): scan_intervals.append(struct.unpack_from('> 5) & 3]) + + if event_type & (1 << self.LEGACY_ADVERTISING_PDU_USED): + legacy_pdu_type = self.LEGACY_PDU_TYPE_MAP.get(event_type & 0x0F) + if legacy_pdu_type is not None: + legacy_info_string = f'({HCI_LE_Advertising_Report_Event.event_type_name(legacy_pdu_type)})' + else: + legacy_info_string = '' + else: + legacy_info_string = '' + + return f'0x{event_type:04X} [{",".join(event_type_flags)}]{legacy_info_string}' + + reports = '\n'.join([report.to_string(' ', { + 'event_type': event_type_string, + 'address_type': Address.address_type_name, + 'data': lambda x: str(AdvertisingData.from_bytes(x)) + }) for report in self.reports]) + + return f'{color(self.subevent_name(self.subevent_code), "magenta")}:\n{reports}' + + +HCI_Event.meta_event_classes[HCI_LE_EXTENDED_ADVERTISING_REPORT_EVENT] = HCI_LE_Extended_Advertising_Report_Event + + # ----------------------------------------------------------------------------- @HCI_LE_Meta_Event.event([ ('connection_handle', 2),