Skip to content

_bleio: support anonymous advertising #2919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2020

Conversation

xobs
Copy link

@xobs xobs commented May 17, 2020

This experimental patch adds a new parameter to _bleio.adapter.start_advertising(): anonymous.

This boolean parameter defaults to False. When set to True, it enables privacy mode by calling sd_ble_gap_privacy_set().

I have tested this on my device, and I confirm that it works -- the address is randomized, and is rotated every 15 minutes. A second device is capable of connecting to a GATT service and communicating.

Unanswered questions:

  • How does this work with bonding?
  • Should we expose the cycle time? It's currently set to 0 which uses the Nordic defaults
  • Should the IRK be exposed anywhere, and does this affect bonding at all?

@xobs
Copy link
Author

xobs commented May 19, 2020

I added a new property timeout that lets a user specify a number of seconds for the advertisement to time out. If no timeout is specified when anonymous mode is requested, then the maximum permitted timeout is selected (currently 180 seconds).

Additionally, I created a new property .advertising that indicates whether the device is still advertising.

xobs added 3 commits May 19, 2020 15:01
Add a new parameter to the `start_advertising()` function to enable
anonymous advertising.  This forces a call to `sd_ble_gap_privacy_set()`
with `privacy_mode` set to `BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY` and
`private_addr_type` set to
`BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE`.

With this, addresses will cycle at a predefined rate (currently once
every 15 minutes).

Signed-off-by: Sean Cross <[email protected]>
Add a field to allow specifying a timeout when initiating advertising.
As part of this, add a new property to determine if the device is still
advertising.

Additionally, have the `anonymous` property require a timeout, and set
the timeout to the maximum possible value if no timeout is specified.

Signed-off-by: Sean Cross <[email protected]>
There is now an adapter timeout message.

Signed-off-by: Sean Cross <[email protected]>
@xobs xobs force-pushed the bleio-anonymous-advertising branch from e20cc02 to f56188c Compare May 19, 2020 07:02
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things. Looks good otherwise! @tannewt, do you have further comments?

@xobs
Copy link
Author

xobs commented May 19, 2020

Thanks for the feedback, @dhalbert . I've made all of those changes as requested.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see a push (and I have a reversal of a request).

The timeout value is calculated by the common-hal layer now, so we don't
need to be quite so clever about calculating it here.

Signed-off-by: Sean Cross <[email protected]>
@xobs
Copy link
Author

xobs commented May 19, 2020

I pushed to the wrong repo. Oops.

Also, alright, I reverted that change. I already added a note to the documentation regarding defaults of timeout when anonymous was specified.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, looks good to me. @tannewt, do you want to take a final look and merge if OK, since you had comments as well? I won't merge right now.

@dhalbert dhalbert requested a review from tannewt May 19, 2020 14:19
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you!

@tannewt tannewt merged commit 4e5df0e into adafruit:master May 19, 2020
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