-
Notifications
You must be signed in to change notification settings - Fork 61
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
[nrf toup][Zephyr] Retry starting BLE advertising after releasing con… #561
Conversation
ff23e97
to
d2b67d8
Compare
d2b67d8
to
11805a9
Compare
9979e02
to
28649af
Compare
…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]>
28649af
to
56f3874
Compare
There was a problem hiding this 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…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.