diff --git a/bumble/device.py b/bumble/device.py index 408b1c9..c84cd40 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -1782,15 +1782,22 @@ class Connection(utils.CompositeEventEmitter): @dataclass class Parameters: - connection_interval: float # Connection interval, in milliseconds. [LE only] - peripheral_latency: int # Peripheral latency, in number of intervals. [LE only] - supervision_timeout: float # Supervision timeout, in milliseconds. - subrate_factor: int = ( - 1 # See Bluetooth spec Vol 6, Part B - 4.5.1 Connection events - ) - continuation_number: int = ( - 0 # See Bluetooth spec Vol 6, Part B - 4.5.1 Connection events - ) + """ + LE connection parameters. + + Attributes: + connection_interval: Connection interval, in milliseconds. + peripheral_latency: Peripheral latency, in number of intervals. + supervision_timeout: Supervision timeout, in milliseconds. + subrate_factor: See Bluetooth spec Vol 6, Part B - 4.5.1 Connection events + continuation_number: See Bluetooth spec Vol 6, Part B - 4.5.1 Connection events + """ + + connection_interval: float + peripheral_latency: int + supervision_timeout: float + subrate_factor: int = 1 + continuation_number: int = 0 def __init__( self, @@ -5413,13 +5420,10 @@ class Device(utils.CompositeEventEmitter): self.emit(self.EVENT_CONNECTION, connection) @host_event_handler - def on_connection_complete( + def on_classic_connection( self, connection_handle: int, peer_address: hci.Address, - connection_interval: int, - peripheral_latency: int, - supervision_timeout: int, ) -> None: connection_role = self.connection_roles.pop(peer_address, hci.Role.PERIPHERAL) @@ -5442,18 +5446,14 @@ class Device(utils.CompositeEventEmitter): peer_address=peer_address, peer_resolvable_address=None, role=connection_role, - parameters=Connection.Parameters( - connection_interval * 1.25, - peripheral_latency, - supervision_timeout * 10.0, - ), + parameters=Connection.Parameters(0.0, 0, 0.0), ) self.connections[connection_handle] = connection self.emit(self.EVENT_CONNECTION, connection) @host_event_handler - def on_le_connection_complete( + def on_le_connection( self, connection_handle: int, peer_address: hci.Address, diff --git a/bumble/host.py b/bumble/host.py index c1afaf2..66b5ed8 100644 --- a/bumble/host.py +++ b/bumble/host.py @@ -992,7 +992,7 @@ class Host(utils.EventEmitter): # Notify the client self.emit( - 'le_connection_complete', + 'le_connection', event.connection_handle, event.peer_address, getattr(event, 'local_resolvable_private_address', None), @@ -1051,12 +1051,9 @@ class Host(utils.EventEmitter): # Notify the client self.emit( - 'connection_complete', + 'classic_connection', event.connection_handle, event.bd_addr, - 0, - 0, - 0, ) else: logger.debug(f'### BR/EDR CONNECTION FAILED: {event.status}') diff --git a/tests/device_test.py b/tests/device_test.py index f8539ec..cc3e063 100644 --- a/tests/device_test.py +++ b/tests/device_test.py @@ -289,7 +289,7 @@ async def test_legacy_advertising_disconnection(auto_restart): await device.power_on() peer_address = Address('F0:F1:F2:F3:F4:F5') await device.start_advertising(auto_restart=auto_restart) - device.on_le_connection_complete( + device.on_le_connection( 0x0001, peer_address, None, @@ -348,7 +348,7 @@ async def test_extended_advertising_connection(own_address_type): advertising_set = await device.create_advertising_set( advertising_parameters=AdvertisingParameters(own_address_type=own_address_type) ) - device.on_le_connection_complete( + device.on_le_connection( 0x0001, peer_address, None, @@ -393,7 +393,7 @@ async def test_extended_advertising_connection_out_of_order(own_address_type): 0x0001, 0, ) - device.on_le_connection_complete( + device.on_le_connection( 0x0001, Address('F0:F1:F2:F3:F4:F5'), None,