Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
)

Expand Down
20 changes: 11 additions & 9 deletions bumble/l2cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 8 additions & 6 deletions bumble/smp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
)

Expand Down
Loading