Skip to content

fix: getting public address from controller only if no address is set#902

Open
yannpoupon wants to merge 1 commit intogoogle:mainfrom
yannpoupon:fix-getting-public-address-from-controller
Open

fix: getting public address from controller only if no address is set#902
yannpoupon wants to merge 1 commit intogoogle:mainfrom
yannpoupon:fix-getting-public-address-from-controller

Conversation

@yannpoupon
Copy link
Copy Markdown

This PR will just try to set the public address from the controller if the user didn't specify any while creating the device

This will allow custom public address to be used in the power_on else it will always be overwritten by this read :

image

@barbibulle
Copy link
Copy Markdown
Collaborator

This may be somewhat dangerous or misleading. Because if the controller has no public address, some operations won't work as expected, when the controller is told, for example, to use its public address for an operation (the field "own_address_type" is used for that in some HCI commands, it can be set to "PUBLIC"). There's no standard HCI command to set the public address (some controllers have private vendor-specific commands for that).
I suppose the question here is: in what scenario would you need to set device.public_address for a controller that doesn't have a public address?

@yannpoupon
Copy link
Copy Markdown
Author

What I am currently trying to do is to set the public address to a specific value and enabling the LE privacy so it uses an RPA and when the connection is done it will resolve the address to the public address I have set

I set the following values before the power_on

address = Address(bytes(addr_bytes), Address.PUBLIC_DEVICE_ADDRESS)
self.public_address = address

# Enable LE privacy so an RPA is generated and rotated periodically.
self.le_privacy_enabled = True
self.le_rpa_timeout = 300 * 60  # 300 minutes

And then I call the power_on that overwrites my public address with 00:00:00:00:00/P

And in the following code it will then check if the public address is different than any since I didn't set the pairing_config :
https://github.com/google/bumble/blob/main/bumble/smp.py#L1027-L1046

And it will then use the static_address and not the public address that I want.

@zxzxwu
Copy link
Copy Markdown
Collaborator

zxzxwu commented Mar 24, 2026

I get what you want to do here. It probably works in SMP, but violates specs, and many controller features will not work or lead to undefined behavior in this way.

@zxzxwu
Copy link
Copy Markdown
Collaborator

zxzxwu commented Mar 24, 2026

BTW, your requirement should be available by setting device.static_address to a public address while keeping identity_address_type = Address.RANDOM_DEVICE_ADDRESS? (Though it's still very weird)

@yannpoupon
Copy link
Copy Markdown
Author

Yes you are right if I set the static address to the address that I want :

address = Address(bytes(addr_bytes), Address.PUBLIC_DEVICE_ADDRESS)
self.static_address = address

# Enable LE privacy so an RPA is generated and rotated periodically.
self.le_privacy_enabled = True
self.le_rpa_timeout = 300 * 60  # 300 minutes

Then the connection works and the address is correctly resolved by the component to the address I set and seen as a public address.

But it just seems weird to set the static_address instead of the public_address with a public address.

@zxzxwu
Copy link
Copy Markdown
Collaborator

zxzxwu commented Mar 26, 2026

I’m leaning against merging this. As we discussed, it’s not a common usage but a bit misleading, and still you can use the workaround for public identity address exchange.

@barbibulle
Copy link
Copy Markdown
Collaborator

What I am currently trying to do is to set the public address to a specific value and enabling the LE privacy so it uses an RPA and when the connection is done it will resolve the address to the public address I have set

I set the following values before the power_on

address = Address(bytes(addr_bytes), Address.PUBLIC_DEVICE_ADDRESS)
self.public_address = address

# Enable LE privacy so an RPA is generated and rotated periodically.
self.le_privacy_enabled = True
self.le_rpa_timeout = 300 * 60  # 300 minutes

And then I call the power_on that overwrites my public address with 00:00:00:00:00/P

And in the following code it will then check if the public address is different than any since I didn't set the pairing_config : https://github.com/google/bumble/blob/main/bumble/smp.py#L1027-L1046

And it will then use the static_address and not the public address that I want.

You could just set device.public_address to whatever you want after calling device.power_on(). It's still brittle (as discussed, not everything will work if the controller doesn't actually have a public address), but should do what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants