Replace legacy transport and role constants

This commit is contained in:
Josh Wu
2025-04-09 17:59:01 +08:00
parent a8019a70da
commit 7569da37e4
33 changed files with 169 additions and 157 deletions

View File

@@ -42,8 +42,7 @@ from bumble.snoop import Snooper
from bumble import drivers
from bumble import hci
from bumble.core import (
BT_BR_EDR_TRANSPORT,
BT_LE_TRANSPORT,
PhysicalTransport,
PhysicalTransport,
ConnectionPHY,
ConnectionParameters,
@@ -200,7 +199,7 @@ class Connection:
self.transport = transport
acl_packet_queue: Optional[DataPacketQueue] = (
host.le_acl_packet_queue
if transport == BT_LE_TRANSPORT
if transport == PhysicalTransport.LE
else host.acl_packet_queue
)
assert acl_packet_queue
@@ -967,7 +966,7 @@ class Host(AbortableEventEmitter):
self,
event.connection_handle,
event.peer_address,
BT_LE_TRANSPORT,
PhysicalTransport.LE,
)
self.connections[event.connection_handle] = connection
@@ -980,7 +979,7 @@ class Host(AbortableEventEmitter):
self.emit(
'connection',
event.connection_handle,
BT_LE_TRANSPORT,
PhysicalTransport.LE,
event.peer_address,
getattr(event, 'local_resolvable_private_address', None),
getattr(event, 'peer_resolvable_private_address', None),
@@ -992,7 +991,10 @@ class Host(AbortableEventEmitter):
# Notify the listeners
self.emit(
'connection_failure', BT_LE_TRANSPORT, event.peer_address, event.status
'connection_failure',
PhysicalTransport.LE,
event.peer_address,
event.status,
)
def on_hci_le_enhanced_connection_complete_event(self, event):
@@ -1017,7 +1019,7 @@ class Host(AbortableEventEmitter):
self,
event.connection_handle,
event.bd_addr,
BT_BR_EDR_TRANSPORT,
PhysicalTransport.BR_EDR,
)
self.connections[event.connection_handle] = connection
@@ -1025,7 +1027,7 @@ class Host(AbortableEventEmitter):
self.emit(
'connection',
event.connection_handle,
BT_BR_EDR_TRANSPORT,
PhysicalTransport.BR_EDR,
event.bd_addr,
None,
None,
@@ -1037,7 +1039,10 @@ class Host(AbortableEventEmitter):
# Notify the client
self.emit(
'connection_failure', BT_BR_EDR_TRANSPORT, event.bd_addr, event.status
'connection_failure',
PhysicalTransport.BR_EDR,
event.bd_addr,
event.status,
)
def on_hci_disconnection_complete_event(self, event):