From 28c097f8451d4718cbceed4ddca2e0e6d6a9815c Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 9 Oct 2026 21:45:14 +0200 Subject: [PATCH] Stop calling the deprecated Host.send_command_sync() Host.send_command_sync() is deprecated in favor of spawning send_async_command() with utils.AsyncRunner.spawn(), but the SMP, L2CAP and Device code still call it, so every pairing, connection parameter update and BR/EDR connection request emits a DeprecationWarning from within Bumble itself. Spawn send_async_command() directly in those places. --- bumble/device.py | 20 ++++++++++++-------- bumble/l2cap.py | 20 +++++++++++--------- bumble/smp.py | 14 ++++++++------ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/bumble/device.py b/bumble/device.py index 9240fe93..6cf93cf1 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -6198,19 +6198,23 @@ def on_connection_request( parameters=Connection.Parameters(0, 0, 0), ) - self.host.send_command_sync( - hci.HCI_Accept_Connection_Request_Command( - bd_addr=bd_addr, - role=0x01, # Remain the peripheral + utils.AsyncRunner.spawn( + self.host.send_async_command( + hci.HCI_Accept_Connection_Request_Command( + bd_addr=bd_addr, + role=0x01, # Remain the peripheral + ) ) ) # reject incoming connection else: - self.host.send_command_sync( - hci.HCI_Reject_Connection_Request_Command( - bd_addr=bd_addr, - reason=hci.HCI_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES_ERROR, + utils.AsyncRunner.spawn( + self.host.send_async_command( + hci.HCI_Reject_Connection_Request_Command( + bd_addr=bd_addr, + reason=hci.HCI_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES_ERROR, + ) ) ) diff --git a/bumble/l2cap.py b/bumble/l2cap.py index 774b8a94..b4f6a983 100644 --- a/bumble/l2cap.py +++ b/bumble/l2cap.py @@ -2553,15 +2553,17 @@ def on_l2cap_connection_parameter_update_request( result=L2CAP_CONNECTION_PARAMETERS_ACCEPTED_RESULT, ), ) - self.host.send_command_sync( - hci.HCI_LE_Connection_Update_Command( - connection_handle=connection.handle, - connection_interval_min=request.interval_min, - connection_interval_max=request.interval_max, - max_latency=request.latency, - supervision_timeout=request.timeout, - min_ce_length=0, - max_ce_length=0, + utils.AsyncRunner.spawn( + self.host.send_async_command( + hci.HCI_LE_Connection_Update_Command( + connection_handle=connection.handle, + connection_interval_min=request.interval_min, + connection_interval_max=request.interval_max, + max_latency=request.latency, + supervision_timeout=request.timeout, + min_ce_length=0, + max_ce_length=0, + ) ) ) else: diff --git a/bumble/smp.py b/bumble/smp.py index 3a90d523..874dcca2 100644 --- a/bumble/smp.py +++ b/bumble/smp.py @@ -1061,12 +1061,14 @@ def send_identity_address_command(self) -> None: def start_encryption(self, key: bytes) -> None: # We can now encrypt the connection with the short term key, so that we can # distribute the long term and/or other keys over an encrypted connection - self.manager.device.host.send_command_sync( - HCI_LE_Enable_Encryption_Command( - connection_handle=self.connection.handle, - random_number=bytes(8), - encrypted_diversifier=0, - long_term_key=key, + utils.AsyncRunner.spawn( + self.manager.device.host.send_async_command( + HCI_LE_Enable_Encryption_Command( + connection_handle=self.connection.handle, + random_number=bytes(8), + encrypted_diversifier=0, + long_term_key=key, + ) ) )