mirror of
https://github.com/google/bumble.git
synced 2026-04-16 00:25:31 +00:00
Refactor find_connection_by_bd_addr
* Compare only address bytes because Address.__eq__ also compares types. * Add a transport field to find connection to a device on specific transport. (It's possible to connect a device on both BR/EDR and LE)
This commit is contained in:
@@ -484,10 +484,11 @@ class Device(CompositeEventEmitter):
|
||||
if connection := self.connections.get(connection_handle):
|
||||
return connection
|
||||
|
||||
def find_connection_by_bd_addr(self, bd_addr):
|
||||
def find_connection_by_bd_addr(self, bd_addr, transport=None):
|
||||
for connection in self.connections.values():
|
||||
if connection.peer_address == bd_addr:
|
||||
return connection
|
||||
if connection.peer_address.get_bytes() == bd_addr.get_bytes():
|
||||
if transport is None or connection.transport == transport:
|
||||
return connection
|
||||
|
||||
def register_l2cap_server(self, psm, server):
|
||||
self.l2cap_channel_manager.register_server(psm, server)
|
||||
|
||||
Reference in New Issue
Block a user