From 94529508a52ef0da6cd88bfd7e49923d127d4837 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Mon, 8 Feb 2021 13:36:28 +0000 Subject: [PATCH] include deprecation option for reversing passkey display --- connectivity/FEATURE_BLE/include/ble/SecurityManager.h | 3 +++ connectivity/FEATURE_BLE/include/ble/common/BLETypes.h | 4 ++++ connectivity/FEATURE_BLE/mbed_lib.json | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/connectivity/FEATURE_BLE/include/ble/SecurityManager.h b/connectivity/FEATURE_BLE/include/ble/SecurityManager.h index b852d08667..c32d0c9c40 100644 --- a/connectivity/FEATURE_BLE/include/ble/SecurityManager.h +++ b/connectivity/FEATURE_BLE/include/ble/SecurityManager.h @@ -324,6 +324,9 @@ public: * @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; diff --git a/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h b/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h index 6771084df6..a2be129318 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h +++ b/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h @@ -272,7 +272,11 @@ public: * @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; diff --git a/connectivity/FEATURE_BLE/mbed_lib.json b/connectivity/FEATURE_BLE/mbed_lib.json index ad105f5b66..b246857f25 100644 --- a/connectivity/FEATURE_BLE/mbed_lib.json +++ b/connectivity/FEATURE_BLE/mbed_lib.json @@ -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": {