From ee09e6f10da5642844ad939c4c68731b66e4bf4d Mon Sep 17 00:00:00 2001 From: Markus Jellitsch Date: Fri, 3 Apr 2026 23:03:51 +0200 Subject: [PATCH] add smp_debug_mode config flag to enable debug keys during device init --- bumble/device.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/bumble/device.py b/bumble/device.py index 65eba87..7d0f2e7 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -558,9 +558,7 @@ class AdvertisingParameters: ) primary_advertising_interval_min: float = DEVICE_DEFAULT_ADVERTISING_INTERVAL primary_advertising_interval_max: float = DEVICE_DEFAULT_ADVERTISING_INTERVAL - primary_advertising_channel_map: ( - hci.HCI_LE_Set_Extended_Advertising_Parameters_Command.ChannelMap - ) = ( + primary_advertising_channel_map: hci.HCI_LE_Set_Extended_Advertising_Parameters_Command.ChannelMap = ( AdvertisingChannelMap.CHANNEL_37 | AdvertisingChannelMap.CHANNEL_38 | AdvertisingChannelMap.CHANNEL_39 @@ -583,9 +581,7 @@ class AdvertisingParameters: class PeriodicAdvertisingParameters: periodic_advertising_interval_min: float = DEVICE_DEFAULT_ADVERTISING_INTERVAL periodic_advertising_interval_max: float = DEVICE_DEFAULT_ADVERTISING_INTERVAL - periodic_advertising_properties: ( - hci.HCI_LE_Set_Periodic_Advertising_Parameters_Command.Properties - ) = field( + periodic_advertising_properties: hci.HCI_LE_Set_Periodic_Advertising_Parameters_Command.Properties = field( default_factory=lambda: hci.HCI_LE_Set_Periodic_Advertising_Parameters_Command.Properties( 0 ) @@ -897,9 +893,7 @@ class PeriodicAdvertisingSync(utils.EventEmitter): options = hci.HCI_LE_Periodic_Advertising_Create_Sync_Command.Options(0) if self.filter_duplicates: - options |= ( - hci.HCI_LE_Periodic_Advertising_Create_Sync_Command.Options.DUPLICATE_FILTERING_INITIALLY_ENABLED - ) + options |= hci.HCI_LE_Periodic_Advertising_Create_Sync_Command.Options.DUPLICATE_FILTERING_INITIALLY_ENABLED await self.device.send_async_command( hci.HCI_LE_Periodic_Advertising_Create_Sync_Command( @@ -1579,12 +1573,8 @@ class CigParameters: worst_case_sca: WorstCaseSca = WorstCaseSca.SCA_251_TO_500_PPM packing: Packing = Packing.SEQUENTIAL framing: Framing = Framing.UNFRAMED - max_transport_latency_c_to_p: int = ( - DEVICE_DEFAULT_ISO_CIS_MAX_TRANSPORT_LATENCY # Max C->P transport latency, in milliseconds - ) - max_transport_latency_p_to_c: int = ( - DEVICE_DEFAULT_ISO_CIS_MAX_TRANSPORT_LATENCY # Max C->P transport latency, in milliseconds - ) + max_transport_latency_c_to_p: int = DEVICE_DEFAULT_ISO_CIS_MAX_TRANSPORT_LATENCY # Max C->P transport latency, in milliseconds + max_transport_latency_p_to_c: int = DEVICE_DEFAULT_ISO_CIS_MAX_TRANSPORT_LATENCY # Max C->P transport latency, in milliseconds # ----------------------------------------------------------------------------- @@ -2159,6 +2149,7 @@ class DeviceConfiguration: ) eatt_enabled: bool = False gatt_services: list[dict[str, Any]] = field(init=False) + smp_debug_mode: bool = False def __post_init__(self) -> None: self.gatt_services = [] @@ -2450,9 +2441,7 @@ class Device(utils.CompositeEventEmitter): self.le_connecting = False self.disconnecting = False self.connections = {} # Connections, by connection handle - self.pending_connections = ( - {} - ) # Pending connections, by BD address (BR/EDR only) + self.pending_connections = {} # Pending connections, by BD address (BR/EDR only) self.sco_links = {} # ScoLinks, by connection handle (BR/EDR only) self.cis_links = {} # CisLinks, by connection handle (LE only) self._pending_cis = {} # (CIS_ID, CIG_ID), by CIS_handle @@ -2571,6 +2560,7 @@ class Device(utils.CompositeEventEmitter): ), ), ) + self.smp_manager.debug_mode = self.config.smp_debug_mode self.l2cap_channel_manager.register_fixed_channel(smp.SMP_CID, self.on_smp_pdu)