Skip to content

Commit

Permalink
Merge pull request google#537 from zxzxwu/smp
Browse files Browse the repository at this point in the history
Ignore invalid RPA
  • Loading branch information
zxzxwu authored Aug 21, 2024
2 parents db383bb + 597560f commit b2bb82a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4281,6 +4281,12 @@ def _complete_le_extended_advertising_connection(
else self.public_address
)

if advertising_set.advertising_parameters.own_address_type in (
OwnAddressType.RANDOM,
OwnAddressType.PUBLIC,
):
connection.self_resolvable_address = None

# Setup auto-restart of the advertising set if needed.
if advertising_set.auto_restart:
connection.once(
Expand Down Expand Up @@ -4327,7 +4333,10 @@ def on_connection(
# Convert all-zeros addresses into None.
if self_resolvable_address == Address.ANY_RANDOM:
self_resolvable_address = None
if peer_resolvable_address == Address.ANY_RANDOM:
if (
peer_resolvable_address == Address.ANY_RANDOM
or not peer_address.is_resolved
):
peer_resolvable_address = None

logger.debug(
Expand Down Expand Up @@ -4361,6 +4370,7 @@ def on_connection(
peer_address = resolved_address

self_address = None
own_address_type: Optional[int] = None
if role == HCI_CENTRAL_ROLE:
own_address_type = self.connect_own_address_type
assert own_address_type is not None
Expand Down Expand Up @@ -4389,6 +4399,11 @@ def on_connection(
else self.random_address
)

# Some controllers may return local resolvable address even not using address
# generation offloading. Ignore the value to prevent SMP failure.
if own_address_type in (OwnAddressType.RANDOM, OwnAddressType.PUBLIC):
self_resolvable_address = None

# Create a connection.
connection = Connection(
self,
Expand Down

0 comments on commit b2bb82a

Please sign in to comment.