Skip to content

Commit 8284807

Browse files
authored
Merge pull request #14239 from paul-szczepanek-arm/passkey-fix
BLE: fix passkey for display being returned reversed
2 parents b512947 + 9452950 commit 8284807

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

connectivity/FEATURE_BLE/include/ble/SecurityManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ class SecurityManager
324324
* @param[in] connectionHandle connection connectionHandle
325325
* @param[in] passkey 6 digit passkey to be displayed
326326
*/
327+
#if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
328+
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.")
329+
#endif // BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
327330
virtual void passkeyDisplay(ble::connection_handle_t connectionHandle, const Passkey_t passkey) {
328331
(void)connectionHandle;
329332
(void)passkey;

connectivity/FEATURE_BLE/include/ble/common/BLETypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ class PasskeyAscii {
272272
* @param[in] passkey value of the data.
273273
*/
274274
PasskeyAscii(passkey_num_t passkey) {
275+
#if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
275276
for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
277+
#else
278+
for (int i = 0, m = 100000; i < PASSKEY_LEN; ++i, m /= 10) {
279+
#endif //BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION
276280
uint32_t result = passkey / m;
277281
ascii[i] = NUMBER_OFFSET + result;
278282
passkey -= result * m;

connectivity/FEATURE_BLE/mbed_lib.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
"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.",
108108
"value": 16,
109109
"macro_name": "BLE_GAP_HOST_PRIVACY_RESOLVED_CACHE_SIZE"
110+
},
111+
"ble-passkey-display-reversed-digits-deprecation": {
112+
"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.",
113+
"value": true,
114+
"macro_name": "BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION"
110115
}
111116
},
112117
"target_overrides": {

0 commit comments

Comments
 (0)