From 9dc5b6b02d6b240ca1692a92f05257077e3016d4 Mon Sep 17 00:00:00 2001 From: "isha.pardikar@espressif.com" Date: Mon, 20 Mar 2023 16:20:09 +0530 Subject: [PATCH] NimBLE: Added configurable option for resolving peer address in bleprph example Closes IDFGH-9552 --- .../nimble/bleprph/main/Kconfig.projbuild | 7 +++++++ examples/bluetooth/nimble/bleprph/main/main.c | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/bluetooth/nimble/bleprph/main/Kconfig.projbuild b/examples/bluetooth/nimble/bleprph/main/Kconfig.projbuild index 8f4d044c31..8b1a160754 100644 --- a/examples/bluetooth/nimble/bleprph/main/Kconfig.projbuild +++ b/examples/bluetooth/nimble/bleprph/main/Kconfig.projbuild @@ -68,4 +68,11 @@ menu "Example Configuration" prompt "Enable Link Encryption" help This adds Encrypted Read and Write permissions in the custom GATT server. + + config EXAMPLE_RESOLVE_PEER_ADDR + bool + prompt "Enable resolving peer address" + help + Use this option to enable resolving peer's address. + endmenu diff --git a/examples/bluetooth/nimble/bleprph/main/main.c b/examples/bluetooth/nimble/bleprph/main/main.c index 655bc2d5d7..29cc75ad90 100644 --- a/examples/bluetooth/nimble/bleprph/main/main.c +++ b/examples/bluetooth/nimble/bleprph/main/main.c @@ -541,6 +541,11 @@ app_main(void) ble_hs_cfg.sm_io_cap = CONFIG_EXAMPLE_IO_TYPE; #ifdef CONFIG_EXAMPLE_BONDING ble_hs_cfg.sm_bonding = 1; + /* Enable the appropriate bit masks to make sure the keys + * that are needed are exchanged + */ + ble_hs_cfg.sm_our_key_dist |= BLE_SM_PAIR_KEY_DIST_ENC; + ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ENC; #endif #ifdef CONFIG_EXAMPLE_MITM ble_hs_cfg.sm_mitm = 1; @@ -550,15 +555,12 @@ app_main(void) #else ble_hs_cfg.sm_sc = 0; #endif -#ifdef CONFIG_EXAMPLE_BONDING - /* Enable the appropriate bit masks to make sure the keys - * that are needed are exchanged - */ - ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC; - ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC; +#ifdef CONFIG_EXAMPLE_RESOLVE_PEER_ADDR + /* Stores the IRK */ + ble_hs_cfg.sm_our_key_dist |= BLE_SM_PAIR_KEY_DIST_ID; + ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ID; #endif - rc = gatt_svr_init(); assert(rc == 0);