mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
only force the type if the address is passed as a string
This commit is contained in:
@@ -1212,15 +1212,16 @@ class Device(CompositeEventEmitter):
|
|||||||
if type(peer_address) is str:
|
if type(peer_address) is str:
|
||||||
try:
|
try:
|
||||||
peer_address = Address(peer_address)
|
peer_address = Address(peer_address)
|
||||||
|
if transport == BT_BR_EDR_TRANSPORT:
|
||||||
|
peer_address.address_type = Address.PUBLIC_DEVICE_ADDRESS
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# If the address is not parsable, assume it is a name instead
|
# If the address is not parsable, assume it is a name instead
|
||||||
logger.debug('looking for peer by name')
|
logger.debug('looking for peer by name')
|
||||||
peer_address = await self.find_peer_by_name(peer_address, transport) # TODO: timeout
|
peer_address = await self.find_peer_by_name(peer_address, transport) # TODO: timeout
|
||||||
|
else:
|
||||||
# All BR/EDR addresses should be public addresses
|
# All BR/EDR addresses should be public addresses
|
||||||
if transport == BT_BR_EDR_TRANSPORT and peer_address.address_type != Address.PUBLIC_DEVICE_ADDRESS:
|
if transport == BT_BR_EDR_TRANSPORT and peer_address.address_type != Address.PUBLIC_DEVICE_ADDRESS:
|
||||||
peer_address = peer_address.clone()
|
raise ValueError('BR/EDR addresses must be PUBLIC')
|
||||||
peer_address.address_type = Address.PUBLIC_DEVICE_ADDRESS
|
|
||||||
|
|
||||||
def on_connection(connection):
|
def on_connection(connection):
|
||||||
if transport == BT_LE_TRANSPORT or (
|
if transport == BT_LE_TRANSPORT or (
|
||||||
|
|||||||
Reference in New Issue
Block a user