From ca16410a6d8bb557035a9944438c8287d0cc57ff Mon Sep 17 00:00:00 2001 From: Abel Lucas Date: Mon, 7 Nov 2022 22:17:01 +0000 Subject: [PATCH] device: add option to check for the address type when using `find_connection_by_bd_addr` --- bumble/device.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bumble/device.py b/bumble/device.py index 7494eb2..b12fad5 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -777,9 +777,11 @@ class Device(CompositeEventEmitter): if connection := self.connections.get(connection_handle): return connection - def find_connection_by_bd_addr(self, bd_addr, transport=None): + def find_connection_by_bd_addr(self, bd_addr, transport=None, check_address_type=False): for connection in self.connections.values(): if connection.peer_address.get_bytes() == bd_addr.get_bytes(): + if check_address_type and connection.peer_address.address_type != bd_addr.address_type: + continue if transport is None or connection.transport == transport: return connection