Skip to content
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

[nrf toup][Zephyr] Retry starting BLE advertising after releasing con… #561

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

ArekBalysNordic
Copy link
Contributor

@ArekBalysNordic ArekBalysNordic commented Feb 26, 2025

…nection.

In Zephyr 4.0, the BT_LE_ADV_OPT_CONNECTABLE and
BT_LE_ADV_OPT_CONNECTABLE advertising options have been deprecated and we need to use BT_LE_ADV_OPT_CONN instead.

Due to the fact that the automatic advertiser resumption is deprecated, we must ensure that the BLE advertising arbiter
restarts advertising in a different way if the service could not be started, for example, due to an existing BLE connection, or the connection has been closed.

We can use the recycled callback of the BT_CONN_CB to check if there is pending request in the list, and if so, try to restart advertising.

…nection.

In Zephyr 4.0, the BT_LE_ADV_OPT_CONNECTABLE and
BT_LE_ADV_OPT_CONNECTABLE advertising options have been deprecated
and we need to use BT_LE_ADV_OPT_CONN instead.

Due to the fact that the automatic advertiser resumption is
deprecated, we must ensure that the BLE advertising arbiter
restarts advertising in a different way if the service could not
be started, for example, due to an existing BLE connection,
or connection has been closed.

We can use the recycled callback of the BT_CONN_CB to check if there
is pending request in the list and if so, try to restart advertising.

Signed-off-by: Arkadiusz Balys <[email protected]>
Copy link
Contributor

@Damian-Nordic Damian-Nordic 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!

.recycled =
[]() {
// In this callback the connection object was returned to the pool and we can try to re-start connectable
// advertising, but only if the disconnection was detected.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious - in which cases where the connection is recycled we don't want to retry the advertising?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This callback is called not only if the disconnection occurs, but on every action that the conn object is released. So, in the case of ChipOverBLE advertising, this callback has been called many times, but actually, there is no need to retry advertising. They deprecated auto-restart on disconnection, so we should take into account only calls if a disconnect occurs to keep previous functionality.

@ArekBalysNordic ArekBalysNordic merged commit 93c7b09 into nrfconnect:master Feb 28, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants