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

BLE Gap deprecation cleanup/rework #12730

Merged
merged 31 commits into from
Apr 27, 2020

Conversation

LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Mar 31, 2020

Preceding PRs:

In conjunction with

Summary of changes

  • Remove BLE LegacyGap class and implementations. Map ble::Gap to global Gap.
  • Add non-deprecated APIs (originally found in LegacyGap) to Gap and implementations into GenericGap.
  • Remove/replace legacy BLE event signalling (callback chains) in favour of EventHandler, where possible.
  • Remove BLEProtocol:: and replace AddressType_t with own_address_type_t/peer_address_type_t, AddressByte_t with address_t, etc.
  • Replace BLE::Address_t (for accessing address types + values in whitelists) with the new equivalent whitelist_t::entry_t.
  • Rename ConnectionParams_t -> PreferredConnectionParams_t and use it only for Generic Access Service.
  • Fix misspelt central_privay_configuration_t -> central_privacy_configuration_t
  • Remove legacy type definitions and replace internal usages with new types, e.g. address types, disconnection reason, etc.

Notes:

  • setDeviceName(), getDeviceName(), setAppearance(), getAppearance() from LegacyGap are removed, as device name and appearance can be set via AdvertisingDataBuilder and saved by the application. But there were previously no deprecation warnings for them.
  • get/setPreferredConnectionParams() are dropped from Gap - updated versions will be added to Gatt where they should belong to.

Impact of changes

Legacy BLE Gap APIs and related type definitions are no longer available.
Some APIs have been updated to take parameters of new type definitions of address types + values.

Migration actions required

  • Applications based on up-to-date BLE APIs should be able to make most BLE function calls as before.
  • However as mentioned above some deprecated types (e.g. address) were not warned previously - their usages need to be replaced with corresponding new types. The best clue is compilation errors which can be manually fixed. The PR to update mbed-os-example-ble is an example of how to do this: Fix deprecated Gap type usages mbed-os-example-ble#289
  • Applications should set device name and appearance using AdvertisingDataBuilder and internally remember their values as needed, since APIs to get/set them are removed as explained above.

Documentation

API documentation is generated with Doxygen. Examples quoted in documentation (e.g. this) are based on ARMmbed/mbed-os-example-ble which requires an update.


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[x] 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)
[x] Tests / results supplied as part of this PR

Manual testing


Reviewers


@ciarmcom ciarmcom requested review from a team March 31, 2020 15:00
@ciarmcom
Copy link
Member

@LDong-Arm, thank you for your changes.
@ARMmbed/mbed-os-pan @ARMmbed/mbed-os-maintainers please review.

@LDong-Arm LDong-Arm changed the title (Preceding PRs, WIP) BLE Gap deprecation cleanup/rework (Preceding PRs) BLE Gap deprecation cleanup/rework Apr 1, 2020
@LDong-Arm
Copy link
Contributor Author

rebased

@LDong-Arm LDong-Arm changed the title (Preceding PRs) BLE Gap deprecation cleanup/rework (WIP, Preceding PRs) BLE Gap deprecation cleanup/rework Apr 3, 2020
@LDong-Arm
Copy link
Contributor Author

@pan- @evedon As per discussion, I have already made one agreed changed (remove get/set preferred connection params API) and created a ticket to reintroduce it in the correct form in the future.

As for the other change (use new address types), it's being worked on but should not take too long. I've marked this PR as WIP in the title.

@LDong-Arm LDong-Arm force-pushed the gap_deprecation_cleanup branch 2 times, most recently from 8cf9023 to 2856adc Compare April 6, 2020 16:36
features/FEATURE_BLE/ble/BLETypes.h Show resolved Hide resolved
features/FEATURE_BLE/ble/gap/Gap.h Show resolved Hide resolved
features/FEATURE_BLE/ble/gap/Gap.h Outdated Show resolved Hide resolved
features/FEATURE_BLE/source/generic/GenericGap.tpp Outdated Show resolved Hide resolved
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.

Thanks Lingkai, it is very promising. I've noticed few improvements that could be applied here and there.

features/FEATURE_BLE/ble/gap/Types.h Outdated Show resolved Hide resolved
}
break;
case peer_address_type_t::RANDOM:
if (!is_random_static_address(entry.address)
Copy link
Member

Choose a reason for hiding this comment

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

The condition can be replace by a test to is_random_private_non_resolvable_address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking is_random_private_non_resolvable_address alone doesn't guard against the scenario where the address value isn't even random.

It brings in another question: the old code only allowed public and random static, whereas the documentation of setWhitelist suggests resolvable private should also work. Were there any limitation that prevented us from whitelisting resolvable private addresses?

Copy link
Member

Choose a reason for hiding this comment

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

There's not much reason of adding a resolvable private address to the list as it change very regularly, you want to put the real address obtained during pairing in the whitelist, the controller should ensure derived resolvable addresses are check against this address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change it. With real addresses things would be simpler here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

features/FEATURE_BLE/source/generic/GenericGap.tpp Outdated Show resolved Hide resolved
features/FEATURE_BLE/source/generic/GenericGap.tpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

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

@pan- Thanks for the review, I'm working on addressing your comments.

}
break;
case peer_address_type_t::RANDOM:
if (!is_random_static_address(entry.address)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking is_random_private_non_resolvable_address alone doesn't guard against the scenario where the address value isn't even random.

It brings in another question: the old code only allowed public and random static, whereas the documentation of setWhitelist suggests resolvable private should also work. Were there any limitation that prevented us from whitelisting resolvable private addresses?

features/FEATURE_BLE/source/generic/GenericGap.tpp Outdated Show resolved Hide resolved
@mbed-ci
Copy link

mbed-ci commented Apr 7, 2020

Test run: FAILED

Summary: 3 of 3 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM-lts
  • jenkins-ci/mbed-os-ci_build-GCC_ARM-lts
  • jenkins-ci/mbed-os-ci_unittests-lts

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 7, 2020

CI lts not related to this PR, will be cleared and proper CI restarted after 5.15 PRs are all integrated

@LDong-Arm
Copy link
Contributor Author

CI lts not related to this PR, will be cleared and proper CI restarted after 5.15 PRs are all integrated

Thanks. I'm still working on this PR and it's not ready for testing either.

@LDong-Arm LDong-Arm requested a review from pan- April 7, 2020 14:41
@LDong-Arm
Copy link
Contributor Author

LDong-Arm commented Apr 7, 2020

@pan- I've addressed your comments, please re-review (the few commits since last review).

Regarding ConnectionParams_t - it's long been replaced by the full-fledged ConnectionParameters for actual connections. However the former is still used by Generic Access Service for a good reason - it's minimal and matches exactly what the specification requires for displaying preferred parameters. So I renamed it to PreferredConnectionParams_t.

LDong-Arm added a commit to LDong-Arm/mbed-os-example-ble that referenced this pull request Apr 7, 2020
In ARMmbed/mbed-os#12730 we have removed
legacy address-related types (BLEProtocol:: namespace) in favour
of new once in ble:: namespace. This commit updates examples
so they continue to work the latest Mbed OS.
@LDong-Arm LDong-Arm changed the title (WIP, Preceding PRs) BLE Gap deprecation cleanup/rework (Preceding PR) BLE Gap deprecation cleanup/rework Apr 7, 2020
LDong-Arm added a commit to LDong-Arm/mbed-os-example-ble that referenced this pull request Apr 7, 2020
In ARMmbed/mbed-os#12730 we have removed
legacy address-related types (BLEProtocol:: namespace) in favour
of new once in ble:: namespace. This commit updates examples
so they continue to work the latest Mbed OS.
LDong-Arm added a commit to LDong-Arm/mbed-os-example-ble that referenced this pull request Apr 8, 2020
In ARMmbed/mbed-os#12730 we have removed
legacy address-related types (BLEProtocol:: namespace) in favour
of new once in ble:: namespace. This commit updates examples
so they continue to work the latest Mbed OS.
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.

Thanks @LDong-Arm that looks very good, did you had the change to try it with ble-cliapp and the test suite ?

The callback on_connected() in ConnectionEventMonitorEventHandler
contains a parameter ConnectionParams_t which is superceded by
ConnectionParameters. Since it's not used, remove it.
For actual connections, full ConnectionParameters is used. But
as per BLE specification, Generic Access Service can display
preferred connection parameters which is a smaller subset and
ConnectionParams_t matches exactly. Thus we rename/repurpose
it to PreferredConnectionParams_t.
@LDong-Arm
Copy link
Contributor Author

Rebased. As said before, this is pending manual testing.

@evedon
Copy link
Contributor

evedon commented Apr 23, 2020

@0xc0170 Could we run CI while we are doing manual tests?

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Apr 23, 2020

Test run: FAILED

Summary: 2 of 3 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM
  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@LDong-Arm
Copy link
Contributor Author

@adbridge @0xc0170 CI failed because this PR has a "chicken-and-egg" dependency on ARMmbed/mbed-os-example-ble#290

@LDong-Arm LDong-Arm changed the title (Manual tests pending) BLE Gap deprecation cleanup/rework BLE Gap deprecation cleanup/rework Apr 24, 2020
@LDong-Arm
Copy link
Contributor Author

I have tested the individual APIs using an updated ble-cliapp + manual commands derived from ble-tests and created reports which are being reviewed by @pan- .

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.

It looks good from all perspectives, thanks @LDong-Arm for your efforts on the test app and test suite!
This PR can be merged when CI pass.

@LDong-Arm
Copy link
Contributor Author

ARMmbed/mbed-os-example-ble#290 is now merged, can we run CI on this PR and get it in so future tests won't break? Thanks

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Apr 24, 2020

Test run: FAILED

Summary: 2 of 3 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM
  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@LDong-Arm
Copy link
Contributor Author

LDong-Arm commented Apr 24, 2020

Just fixed an issue in one of the examples: https://github.com/ARMmbed/mbed-os-example-ble/pull/294/files (merged).
Hopefully CI will pass once we re-run! 🙏

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 27, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Apr 27, 2020

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 merged commit 28ef753 into ARMmbed:master Apr 27, 2020
@0xc0170 0xc0170 removed the needs: CI label Apr 27, 2020
paul-szczepanek-arm pushed a commit to ARMmbed/mbed-os-example-ble that referenced this pull request Sep 10, 2020
In ARMmbed/mbed-os#12730 we have removed
legacy address-related types (BLEProtocol:: namespace) in favour
of new once in ble:: namespace. This commit updates examples
so they continue to work the latest Mbed OS.
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.

7 participants