From 9ac7b161245de46a4daf550b7c6903973d61ac45 Mon Sep 17 00:00:00 2001 From: zwj Date: Thu, 15 Dec 2022 15:10:52 +0800 Subject: [PATCH] Update bt lib for ESP32 - Add config to set duplicate scan list refresh period - overwrite the oldest device infor if the list is full - Fixed duplicate scan period is not accurate --- components/bt/controller/esp32/Kconfig.in | 16 ++++++++++++++++ components/bt/controller/esp32c3/Kconfig.in | 2 +- components/bt/controller/esp32s3/Kconfig.in | 2 +- components/bt/controller/lib_esp32 | 2 +- components/bt/include/esp32/include/esp_bt.h | 10 +++++++++- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 44c95c28647b..f9a505cf2561 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -353,6 +353,22 @@ config BTDM_SCAN_DUPL_CACHE_SIZE Maximum number of devices which can be recorded in scan duplicate filter. When the maximum amount of device in the filter is reached, the cache will be refreshed. +config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD + int "Duplicate scan list refresh period (seconds)" + depends on BTDM_BLE_SCAN_DUPL + range 0 1000 + default 0 + help + If the period value is non-zero, the controller will periodically clear the device information + stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared + until the scanning is disabled. Duplicate advertisements for this period should not be sent to the + Host in advertising report events. + There are two scenarios where the ADV packet will be repeatedly reported: + 1. The duplicate scan cache is full, the controller will delete the oldest device information and + add new device information. + 2. When the refresh period is up, the controller will clear all device information and start filtering + again. + config BTDM_BLE_MESH_SCAN_DUPL_EN bool "Special duplicate scan mechanism for BLE Mesh scan" depends on BTDM_BLE_SCAN_DUPL diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index efd72857f780..1821f154c9db 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -281,7 +281,7 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE When the maximum amount of device in the filter is reached, the cache will be refreshed. config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD - int "Duplicate scan list refresh period" + int "Duplicate scan list refresh period (seconds)" depends on BT_CTRL_BLE_SCAN_DUPL range 0 1000 default 0 diff --git a/components/bt/controller/esp32s3/Kconfig.in b/components/bt/controller/esp32s3/Kconfig.in index 663e63b90b6b..ac4aadd1e3e9 100644 --- a/components/bt/controller/esp32s3/Kconfig.in +++ b/components/bt/controller/esp32s3/Kconfig.in @@ -298,7 +298,7 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE When the maximum amount of device in the filter is reached, the cache will be refreshed. config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD - int "Duplicate scan list refresh period" + int "Duplicate scan list refresh period (seconds)" depends on BT_CTRL_BLE_SCAN_DUPL range 0 1000 default 0 diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index bdb57a2c5e4b..d4a224c5d682 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit bdb57a2c5e4bd6a5d7f34417b280680ce700605e +Subproject commit d4a224c5d682d6b5a76542c6918b6a59dd0b2f8c diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index bf71c48eb751..f048ff37e651 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -50,7 +50,7 @@ extern "C" { #endif //CONFIG_BT_ENABLED -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200622 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207 /** * @brief Bluetooth mode for controller enable/disable @@ -128,6 +128,12 @@ the adv packet will be discarded until the memory is restored. */ #define MESH_DUPLICATE_SCAN_CACHE_SIZE 0 #endif +#ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD +#define SCAN_DUPL_CACHE_REFRESH_PERIOD CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD +#else +#define SCAN_DUPL_CACHE_REFRESH_PERIOD 0 +#endif + #if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY) #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE #elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY) @@ -183,6 +189,7 @@ the adv packet will be discarded until the memory is restored. */ .pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \ .pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \ .hli = BTDM_CTRL_HLI, \ + .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -225,6 +232,7 @@ typedef struct { uint8_t pcm_role; /*!< PCM role (master & slave)*/ uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */ bool hli; /*!< Using high level interrupt or not */ + uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t;