From 4fb4c01c53eb5371263e5474d8c4523769d03112 Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Fri, 13 Mar 2020 13:11:08 +0530 Subject: [PATCH] NimBLE: Add Host based privacy (RPA) feature support (v3.3) - This feature removes dependency on controller to use privacy (RPA) --- components/bt/Kconfig | 9 +++++++++ components/nimble/CMakeLists.txt | 1 + components/nimble/nimble | 2 +- components/nimble/port/include/esp_nimble_cfg.h | 6 +++++- examples/bluetooth/nimble/bleprph/README.md | 4 +++- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index a90402ac8..6f990efdb 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -1597,6 +1597,15 @@ menu Bluetooth Enable this option to send number-of-completed-packets event to controller after disconnection + config NIMBLE_RPA_TIMEOUT + int "RPA timeout in seconds" + range 1 41400 + depends on NIMBLE_ENABLED + default 900 + help + Time interval between RPA address change. This is applicable in case of + Host based RPA + menuconfig NIMBLE_MESH bool "Enable BLE mesh functionality" select NIMBLE_SM_SC diff --git a/components/nimble/CMakeLists.txt b/components/nimble/CMakeLists.txt index 95f4fb949..ce92e7f81 100644 --- a/components/nimble/CMakeLists.txt +++ b/components/nimble/CMakeLists.txt @@ -70,6 +70,7 @@ if(CONFIG_NIMBLE_ENABLED) "./nimble/nimble/host/src/ble_hs_adv.c" "./nimble/nimble/host/src/ble_hs_hci.c" "./nimble/nimble/host/src/ble_hs_hci_util.c" + "./nimble/nimble/host/src/ble_hs_resolv.c" "./nimble/nimble/host/store/ram/src/ble_store_ram.c" "./nimble/nimble/host/store/config/src/ble_store_config.c" "./nimble/nimble/host/store/config/src/ble_store_nvs.c" diff --git a/components/nimble/nimble b/components/nimble/nimble index c876cbcbc..ecb1e9e5e 160000 --- a/components/nimble/nimble +++ b/components/nimble/nimble @@ -1 +1 @@ -Subproject commit c876cbcbc2b1fcae257d8f921083eebf0964eef5 +Subproject commit ecb1e9e5e3efb830d0b04dc3382be7b1012fdeaa diff --git a/components/nimble/port/include/esp_nimble_cfg.h b/components/nimble/port/include/esp_nimble_cfg.h index 7bc749cca..3c9957518 100644 --- a/components/nimble/port/include/esp_nimble_cfg.h +++ b/components/nimble/port/include/esp_nimble_cfg.h @@ -535,8 +535,12 @@ #define MYNEWT_VAL_BLE_MONITOR_UART_DEV ("uart0") #endif +#ifndef MYNEWT_VAL_BLE_HOST_BASED_PRIVACY +#define MYNEWT_VAL_BLE_HOST_BASED_PRIVACY (1) +#endif + #ifndef MYNEWT_VAL_BLE_RPA_TIMEOUT -#define MYNEWT_VAL_BLE_RPA_TIMEOUT (300) +#define MYNEWT_VAL_BLE_RPA_TIMEOUT (CONFIG_NIMBLE_RPA_TIMEOUT) #endif #ifndef MYNEWT_VAL_BLE_SM_BONDING diff --git a/examples/bluetooth/nimble/bleprph/README.md b/examples/bluetooth/nimble/bleprph/README.md index b518c81f8..0fb0ee494 100644 --- a/examples/bluetooth/nimble/bleprph/README.md +++ b/examples/bluetooth/nimble/bleprph/README.md @@ -10,9 +10,11 @@ This example aims at understanding GATT database configuration, advertisement an It also demonstrates security features of NimBLE stack. SMP parameters like I/O capabilities of device, Bonding flag, MITM protection flag and Secure Connection only mode etc., can be configured through menuconfig options. +For RPA feature (currently Host based privacy feature is supported), use API `ble_hs_pvcy_rpa_config` to enable/disable host based privacy, `own_addr_type` needs to be set to `BLE_ADDR_RANDOM` to use this feature. Please include `ble_hs_pvcy.h` while using this API. As `ble_hs_pvcy_rpa_config` configures host privacy and sets address in controller, it is necessary to call this API after host-controller are synced (e.g. in `bleprph_on_sync` callback). + To test this demo, any BLE scanner app can be used. -A Python based utility `bleprph_test.py` is also provided (which will run as a BLE GATT Client) and can be used to test this example. +A Python based utility `bleprph_test.py` is also provided (which will run as a BLE GATT Client) and can be used to test this example. Note :