From 48bd2d74b4209bbad7c29d2d856810ee43a1a92c Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Fri, 6 Mar 2020 11:02:18 +0800 Subject: [PATCH] NimBLE: Add Host based privacy (RPA) feature support - This feature removes dependency on controller to use privacy (RPA) --- components/bt/CMakeLists.txt | 1 + components/bt/host/nimble/Kconfig.in | 9 +++++++++ components/bt/host/nimble/nimble | 2 +- components/bt/host/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/CMakeLists.txt b/components/bt/CMakeLists.txt index 5add11c0d..60dfa1f46 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -480,6 +480,7 @@ if(CONFIG_BT_ENABLED) "host/nimble/nimble/nimble/host/src/ble_hs_adv.c" "host/nimble/nimble/nimble/host/src/ble_hs_hci.c" "host/nimble/nimble/nimble/host/src/ble_hs_hci_util.c" + "host/nimble/nimble/nimble/host/src/ble_hs_resolv.c" "host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c" "host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c" "host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c" diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index 6bc525eb1..275bd9d23 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -257,6 +257,15 @@ config BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT Enable this option to send number-of-completed-packets event to controller after disconnection +config BT_NIMBLE_RPA_TIMEOUT + int "RPA timeout in seconds" + range 1 41400 + depends on BT_NIMBLE_ENABLED + default 900 + help + Time interval between RPA address change. This is applicable in case of + Host based RPA + menuconfig BT_NIMBLE_MESH bool "Enable BLE mesh functionality" select BT_NIMBLE_SM_SC diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index d60a322f5..e4e2b5014 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit d60a322f54cdad95f842b9fabb026615745da1a3 +Subproject commit e4e2b501410bf60d2f09e62bfd8230074dfaa2c9 diff --git a/components/bt/host/nimble/port/include/esp_nimble_cfg.h b/components/bt/host/nimble/port/include/esp_nimble_cfg.h index 8818a2849..9f30d62e7 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -543,8 +543,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_BT_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..76c4f23ea 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. + 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 :