Skip to content

BLE: Fix advertising start and stop #14672

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 11 commits into from
Jun 9, 2021

Conversation

paul-szczepanek-arm
Copy link
Member

@paul-szczepanek-arm paul-szczepanek-arm commented May 17, 2021

Summary of changes

The start and stop commands for advertising need to complete before the next one is issued. Serialise commands to start and stop advertising. Introduces a new event since the command is now async.
I have also simplified the reset since it doesn't need to start or stop anything - it should rely on the controller to clear the sets.

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


Copy link
Member

@pan- pan- left a comment

Choose a reason for hiding this comment

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

This could help for general case but I'm not sure it helps if the user, for example, start advertising sets with different parameters in a for loop as the configuration will change multiple times before extended_advertising_enable is actually called. That would lead to subtle bugs.

Have you considered the option where the user is responsible to start and stop advertising sequentially ? We can return an error if a request is pending and indicate its status on AdvertisingStartEvent or AdvertisingEndEvent.

@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label May 17, 2021
@ciarmcom ciarmcom requested a review from a team May 17, 2021 20:00
@ciarmcom
Copy link
Member

@paul-szczepanek-arm, thank you for your changes.
@ARMmbed/mbed-os-maintainers please review.

@paul-szczepanek-arm
Copy link
Member Author

If he calls start advertising multiple times then the first one will succeed and the subsequent ones will fail. Don't see the subtle bug.

/* stop all advertising sets */
for (size_t i = 0; i < BLE_GAP_MAX_ADVERTISING_SETS; ++i) {
if (_active_sets.get(i)) {
_pal_gap.extended_advertising_enable(
Copy link
Member Author

Choose a reason for hiding this comment

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

this is redundant since the controller clears the sets

@paul-szczepanek-arm paul-szczepanek-arm changed the title BLE: Fix advertising start and stop [WIP] BLE: Fix advertising start and stop May 18, 2021
@paul-szczepanek-arm paul-szczepanek-arm requested a review from pan- May 18, 2021 10:14
@paul-szczepanek-arm
Copy link
Member Author

Note to self: fixes #14650

@AGlass0fMilk
Copy link
Member

Another bug in Gap::reset():

If you disable BLE_ROLE_OBSERVER there will be an undefined reference to set_scan_state.

See my patch commit here:
AGlass0fMilk@2a7cbf3

@paul-szczepanek-arm Making note of this for you, this should be fixed as you refactor the GAP implementation.

@paul-szczepanek-arm
Copy link
Member Author

Thanks, looks like there are quite a few places where observer flag is missing.

0xc0170
0xc0170 previously approved these changes May 19, 2021
@mergify mergify bot added needs: CI and removed needs: review labels May 19, 2021
@pan-
Copy link
Member

pan- commented Jun 1, 2021

Do you wish for me to ignore this request then and you'll make a jira ticket for this change?

Please ignore that request for this fix, it will be logged in Jira.

@mergify mergify bot dismissed stale reviews from 0xc0170 and pan- June 1, 2021 21:47

Pull request has been modified.

@paul-szczepanek-arm paul-szczepanek-arm requested a review from pan- June 2, 2021 13:44
@paul-szczepanek-arm
Copy link
Member Author

The set end event is currently issued incorrectly but that will be a new PR so this is good to go.
(BLE example still fails because it had a bug of its own, fixed here: ARMmbed/mbed-os-example-ble#380)

@adbridge
Copy link
Contributor

adbridge commented Jun 4, 2021

@pan- could you re-review to make sure you are happy with all the changes ?

pan-
pan- previously approved these changes Jun 8, 2021
@mergify mergify bot added needs: CI and removed needs: review labels Jun 8, 2021
@mergify mergify bot dismissed pan-’s stale review June 8, 2021 08:49

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 8, 2021

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 8, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit e377383 into ARMmbed:master Jun 9, 2021
@mergify mergify bot removed the ready for merge label Jun 9, 2021
@mbedmain mbedmain added release-version: 6.12.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Jun 18, 2021
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.

8 participants