From 6ba1a3a42758b7fa03251ffba0eb423912aab38a Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Mon, 19 May 2025 12:04:41 +0800 Subject: [PATCH] feat(ble): support creating connections during scanning process on ESP32-C5 (cherry picked from commit 9d687daf36c011c0c1b7753075d5e02492b6fa05) Co-authored-by: zwl --- components/bt/controller/esp32c5/Kconfig.in | 7 +++++++ components/bt/controller/esp32c5/bt.c | 11 +---------- components/bt/controller/esp32c5/esp_bt_cfg.h | 6 ++++++ components/bt/include/esp32c5/include/esp_bt.h | 10 +++++++++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/components/bt/controller/esp32c5/Kconfig.in b/components/bt/controller/esp32c5/Kconfig.in index be28c7e376..989bb52df9 100644 --- a/components/bt/controller/esp32c5/Kconfig.in +++ b/components/bt/controller/esp32c5/Kconfig.in @@ -805,3 +805,10 @@ config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX config BT_LE_RXBUF_OPT_ENABLED bool "Enable rxbuf optimization feature" default y + +config BT_LE_CTRL_FAST_CONN_DATA_TX_EN + bool "Enable fast sending of connection data" + default y + help + If this option is enabled, The Controller will continue to + Send an empty PDU after sending valid connection data within an interval. diff --git a/components/bt/controller/esp32c5/bt.c b/components/bt/controller/esp32c5/bt.c index da65ecd10e..37c2fa6601 100644 --- a/components/bt/controller/esp32c5/bt.c +++ b/components/bt/controller/esp32c5/bt.c @@ -67,7 +67,7 @@ #define OSI_COEX_VERSION 0x00010006 #define OSI_COEX_MAGIC_VALUE 0xFADEBEAD -#define EXT_FUNC_VERSION 0x20240422 +#define EXT_FUNC_VERSION 0x20250415 #define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5 #define BT_ASSERT_PRINT ets_printf @@ -98,14 +98,12 @@ struct ext_funcs_t { int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv); int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y, const uint8_t *local_priv_key, uint8_t *dhkey); - void (* _esp_reset_rpa_moudle)(void); uint32_t magic; }; #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED - /* External functions or variables ************************************************************************ */ @@ -182,7 +180,6 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, static int esp_intr_free_wrapper(void **ret_handle); static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2); static uint32_t osi_random_wrapper(void); -static void esp_reset_rpa_moudle(void); static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv); static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y, const uint8_t *our_priv_key, uint8_t *out_dhkey); @@ -459,15 +456,9 @@ struct ext_funcs_t ext_funcs_ro = { ._os_random = osi_random_wrapper, ._ecc_gen_key_pair = esp_ecc_gen_key_pair, ._ecc_gen_dh_key = esp_ecc_gen_dh_key, - ._esp_reset_rpa_moudle = esp_reset_rpa_moudle, .magic = EXT_FUNC_MAGIC_VALUE, }; -static void IRAM_ATTR esp_reset_rpa_moudle(void) -{ - -} - static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2) { diff --git a/components/bt/controller/esp32c5/esp_bt_cfg.h b/components/bt/controller/esp32c5/esp_bt_cfg.h index 6621c28cb4..48a845a3fa 100644 --- a/components/bt/controller/esp32c5/esp_bt_cfg.h +++ b/components/bt/controller/esp32c5/esp_bt_cfg.h @@ -192,6 +192,12 @@ extern "C" { #define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0) #endif +#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN) +#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN) +#else +#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (0) +#endif + #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART #else diff --git a/components/bt/include/esp32c5/include/esp_bt.h b/components/bt/include/esp32c5/include/esp_bt.h index 3333adee4b..35dd2c21a1 100644 --- a/components/bt/include/esp32c5/include/esp_bt.h +++ b/components/bt/include/esp32c5/include/esp_bt.h @@ -159,7 +159,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 0x20250310 +#define CONFIG_VERSION 0x20250513 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -226,6 +226,11 @@ typedef struct { - 1 - Enable */ uint8_t vhci_enabled; /*!< VHCI mode is enabled */ uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */ + uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */ + uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform extra handling for fatal checks. */ + uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data + - 0 - Disable + - 1 - Enable (default) */ uint32_t config_magic; /*!< Magic number for configuration validation */ } esp_bt_controller_config_t; @@ -281,6 +286,9 @@ typedef struct { .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \ .ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \ + .ble_adv_tx_options = 0, \ + .skip_unnecessary_checks_en = 0, \ + .fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \ .config_magic = CONFIG_MAGIC, \ }