address PR comments
diff --git a/bumble/device.py b/bumble/device.py
index 6ff5a97..4b3fa43 100644
--- a/bumble/device.py
+++ b/bumble/device.py
@@ -1211,9 +1211,7 @@
if type(peer_address) is str:
try:
- peer_address = Address(peer_address)
- if transport == BT_BR_EDR_TRANSPORT:
- peer_address.address_type = Address.PUBLIC_DEVICE_ADDRESS
+ peer_address = Address.from_string_for_transport(peer_address, transport)
except ValueError:
# If the address is not parsable, assume it is a name instead
logger.debug('looking for peer by name')
diff --git a/bumble/hci.py b/bumble/hci.py
index 387f3ff..1527c92 100644
--- a/bumble/hci.py
+++ b/bumble/hci.py
@@ -1667,6 +1667,14 @@
return name_or_number(Address.ADDRESS_TYPE_NAMES, address_type)
@staticmethod
+ def from_string_for_transport(string, transport):
+ if transport == BT_BR_EDR_TRANSPORT:
+ address_type = Address.PUBLIC_DEVICE_ADDRESS
+ else:
+ address_type = Address.RANDOM_DEVICE_ADDRESS
+ return Address(string, address_type)
+
+ @staticmethod
def parse_address(data, offset):
# Fix the type to a default value. This is used for parsing type-less Classic addresses
return Address.parse_address_with_type(data, offset, Address.PUBLIC_DEVICE_ADDRESS)