Skip to content

BLE: fix passkey for display being returned reversed #14239

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 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions connectivity/FEATURE_BLE/include/ble/SecurityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ class SecurityManager
* @param[in] connectionHandle connection connectionHandle
* @param[in] passkey 6 digit passkey to be displayed
*/
#if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
MBED_DEPRECATED_SINCE("mbed-os-6.8.0", "This returns the passkey in reverse order. Please set the config option ble.ble-passkey-display-reversed-digits-deprecation in your mbed_app.json override section to false. This will then return the passkey in the correct order.")
#endif // BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
virtual void passkeyDisplay(ble::connection_handle_t connectionHandle, const Passkey_t passkey) {
(void)connectionHandle;
(void)passkey;
Expand Down
4 changes: 4 additions & 0 deletions connectivity/FEATURE_BLE/include/ble/common/BLETypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,11 @@ class PasskeyAscii {
* @param[in] passkey value of the data.
*/
PasskeyAscii(passkey_num_t passkey) {
#if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
#else
for (int i = 0, m = 100000; i < PASSKEY_LEN; ++i, m /= 10) {
#endif //BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
uint32_t result = passkey / m;
ascii[i] = NUMBER_OFFSET + result;
passkey -= result * m;
Expand Down
5 changes: 5 additions & 0 deletions connectivity/FEATURE_BLE/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
"help": "Used for host privacy. How many last resolved addresses to store to speed up resolution. This is especially valuable for resolving advertising which creates repeated queries for the same address.",
"value": 16,
"macro_name": "BLE_GAP_HOST_PRIVACY_RESOLVED_CACHE_SIZE"
},
"ble-passkey-display-reversed-digits-deprecation": {
"help": "This option is part of the deprecation process. Set this to false to remove the deprecation notice. When set to true, the digits in the SecurityManager passkeyDiplay event are reversed. When set to false the digits are in the correct order.",
"value": true,
"macro_name": "BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION"
}
},
"target_overrides": {
Expand Down