From e4e42f01661d2d74b392195e51e2fe558fcf9dc0 Mon Sep 17 00:00:00 2001 From: cjin Date: Tue, 13 Jan 2026 10:21:59 +0800 Subject: [PATCH] feat(ble): support sid filter feature on ESP32H2 --- components/bt/controller/esp32h2/ble.c | 23 ++++++++++++++++++- components/bt/controller/esp32h2/esp_bt_cfg.h | 14 ++++++++++- .../bt/include/esp32h2/include/esp_bt.h | 4 +++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32h2/ble.c b/components/bt/controller/esp32h2/ble.c index 0b6fc1e7d0..411c0a69f9 100644 --- a/components/bt/controller/esp32h2/ble.c +++ b/components/bt/controller/esp32h2/ble.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,6 +27,11 @@ void extAdv_stack_deinitEnv(void); int extAdv_stack_enable(void); void extAdv_stack_disable(void); +int scan_stack_initEnv(void); +void scan_stack_deinitEnv(void); +int scan_stack_enable(void); +void scan_stack_disable(void); + int sync_stack_initEnv(void); void sync_stack_deinitEnv(void); int sync_stack_enable(void); @@ -84,6 +89,10 @@ void winWiden_stack_enableSetConstPeerScaVsCmd(bool en); void adv_stack_enableScanReqRxdVsEvent(bool en); void conn_stack_enableChanMapUpdCompVsEvent(bool en); void sleep_stack_enableWakeupVsEvent(bool en); +#if DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER +void scan_stack_enableSetScanADIOnlyFilterVsCmd(bool en); +#endif // DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER +void extAdv_stack_setExtAdvConstantDidVsCmd(bool en); #endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) #if CONFIG_BT_LE_RXBUF_OPT_ENABLED extern void mmgmt_enableRxbufOptFeature(void); @@ -136,6 +145,11 @@ int ble_stack_initEnv(void) return rc; } + rc = scan_stack_initEnv(); + if (rc) { + return rc; + } + rc = sync_stack_initEnv(); if (rc) { return rc; @@ -210,6 +224,7 @@ void ble_stack_deinitEnv(void) #endif // CONFIG_BT_LE_DTM_ENABLED sync_stack_deinitEnv(); + scan_stack_deinitEnv(); extAdv_stack_deinitEnv(); adv_stack_deinitEnv(); base_stack_deinitEnv(); @@ -234,6 +249,11 @@ int ble_stack_enable(void) return rc; } + rc = scan_stack_enable(); + if (rc) { + return rc; + } + rc = sync_stack_enable(); if (rc) { return rc; @@ -302,6 +322,7 @@ void ble_stack_disable(void) dtm_stack_disable(); #endif // CONFIG_BT_LE_DTM_ENABLED sync_stack_disable(); + scan_stack_disable(); extAdv_stack_disable(); adv_stack_disable(); base_stack_disable(); diff --git a/components/bt/controller/esp32h2/esp_bt_cfg.h b/components/bt/controller/esp32h2/esp_bt_cfg.h index 15041ccd63..a309a7fd54 100644 --- a/components/bt/controller/esp32h2/esp_bt_cfg.h +++ b/components/bt/controller/esp32h2/esp_bt_cfg.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -51,6 +51,16 @@ extern "C" { #else #define DEFAULT_BT_LE_PAWR_SUPPORTED (0) #endif // CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES + #if CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID + #define DEFAULT_BT_ADV_SEND_CONSTANT_DID (1) + #else + #define DEFAULT_BT_ADV_SEND_CONSTANT_DID (0) + #endif // CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID + #if CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER + #define DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER (1) + #else + #define DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER (0) + #endif // CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER #else #if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY @@ -163,6 +173,8 @@ extern "C" { #define DEFAULT_BT_LE_HCI_UART_CTS_PIN (-1) #define DEFAULT_BT_LE_HCI_UART_RTS_PIN (-1) #endif + #define DEFAULT_BT_ADV_SEND_CONSTANT_DID (0) + #define DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER (0) #endif #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index 28783c40ec..d4bbabe79e 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -161,7 +161,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20251125 +#define CONFIG_VERSION 0x20251211 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -239,6 +239,7 @@ typedef struct { uint8_t priority_level_cfg; /*!< The option for priority level configuration */ uint8_t slv_fst_rx_lat_en; /*!< The option for enabling slave fast PDU reception during latency. */ uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update when phy update or connect interval update. */ + uint8_t scan_allow_adi_filter; /*!< The option for ext scan to allow PDU with specific adi. */ uint32_t config_magic; /*!< Configuration magic value */ } esp_bt_controller_config_t; @@ -304,6 +305,7 @@ typedef struct { .priority_level_cfg = BT_LL_CTRL_PRIO_LVL_CFG, \ .slv_fst_rx_lat_en = DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN, \ .dl_itvl_phy_sync_en = DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN, \ + .scan_allow_adi_filter = DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER, \ .config_magic = CONFIG_MAGIC, \ }