Skip to content

Commit e6b590b

Browse files
Zhou Xiaozhaoweiliang2021
andcommitted
feat(ble): add channel assessment and enhanced connect function on ESP32-H2
(cherry picked from commit 0ffac92) Co-authored-by: zwl <zhaoweiliang@espressif.com>
1 parent b9616fd commit e6b590b

File tree

3 files changed

+110
-14
lines changed

3 files changed

+110
-14
lines changed

components/bt/controller/esp32h2/Kconfig.in

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
658658
again.
659659

660660
config BT_LE_MSYS_INIT_IN_CONTROLLER
661-
bool
661+
bool "Msys Mbuf Init in Controller"
662662
default y
663663

664664
config BT_LE_TX_CCA_ENABLED
@@ -749,3 +749,48 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
749749
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
750750
Because the code is moved to the flash, the execution speed of the code is reduced.
751751
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
752+
753+
menu "BLE disconnects when Instant Passed (0x28) occurs"
754+
config BT_LE_CTRL_LLCP_CONN_UPDATE
755+
bool "BLE ACL connection update procedure"
756+
default n
757+
help
758+
If this option is enabled, Controller will terminate the connection
759+
when Instant Passed (0x28) error occurs during connection update procedure.
760+
761+
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
762+
bool "BLE ACL channel map update procedure"
763+
default n
764+
help
765+
If this option is enabled, Controller will terminate the connection
766+
when Instant Passed (0x28) error occurs in channel map update procedure.
767+
768+
config BT_LE_CTRL_LLCP_PHY_UPDATE
769+
bool "BLE ACL PHY update procedure"
770+
default n
771+
help
772+
If this option is enabled, Controller will terminate the connection
773+
when Instant Passed (0x28) error occurs in PHY update procedure.
774+
endmenu
775+
776+
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
777+
int "The value of upperlimitmax during scan backoff procedure"
778+
range 1 256
779+
default 32
780+
help
781+
The value of upperlimitmax needs to be a power of 2.
782+
783+
config BT_LE_CTRL_CHAN_ASS_EN
784+
bool "Enable channel assessment"
785+
default n
786+
help
787+
If this option is enabled, The Controller will records the communication quality
788+
for each channel and then start a timer to check and update the channel map every 4 seconds.
789+
790+
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
791+
bool "Enable aux packet when ext adv data length is zero"
792+
default y
793+
help
794+
When this option is enabled, auxiliary packets will be present in the events of
795+
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
796+
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.

components/bt/controller/esp32h2/esp_bt_cfg.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -154,6 +154,44 @@ extern "C" {
154154
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
155155
#endif
156156

157+
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
158+
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
159+
#else
160+
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
161+
#endif
162+
163+
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
164+
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
165+
#else
166+
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
167+
#endif
168+
169+
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
170+
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
171+
#else
172+
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
173+
#endif
174+
175+
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
176+
177+
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
178+
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
179+
#else
180+
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
181+
#endif
182+
183+
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
184+
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
185+
#else
186+
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (0)
187+
#endif
188+
189+
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
190+
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
191+
#else
192+
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
193+
#endif
194+
157195
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
158196
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
159197
#else

components/bt/include/esp32h2/include/esp_bt.h

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -109,14 +109,6 @@ typedef enum {
109109
ESP_BLE_ENHANCED_PWR_TYPE_MAX,
110110
} esp_ble_enhanced_power_type_t;
111111

112-
/**
113-
* @brief Address type and address value.
114-
*/
115-
typedef struct {
116-
uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
117-
uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
118-
} esp_ble_addr_t;
119-
120112
/**
121113
* @brief Select buffers
122114
*/
@@ -125,6 +117,14 @@ typedef enum {
125117
ESP_BLE_LOG_BUF_CONTROLLER = 0x05,
126118
} esp_ble_log_buf_t;
127119

120+
/**
121+
* @brief Address type and address value.
122+
*/
123+
typedef struct {
124+
uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
125+
uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
126+
} esp_ble_addr_t;
127+
128128
/**
129129
* @brief Set BLE TX power
130130
* Connection Tx power should only be set after connection created.
@@ -161,7 +161,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
161161
*/
162162
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
163163

164-
#define CONFIG_VERSION 0x20241121
164+
#define CONFIG_VERSION 0x20250104
165165
#define CONFIG_MAGIC 0x5A5AA5A5
166166

167167
/**
@@ -217,7 +217,16 @@ typedef struct {
217217
uint8_t csa2_select; /*!< Select CSA#2*/
218218
uint8_t enable_csr; /*!< Enable CSR */
219219
uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
220-
uint32_t config_magic; /*!< Configuration magic value */
220+
uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
221+
- The Controller does not disconnect after Instant Passed (0x28) by default. */
222+
uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
223+
uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
224+
- 0 - Disable
225+
- 1 - Enable (default) */
226+
uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
227+
- 0 - Disable (default)
228+
- 1 - Enable */
229+
uint32_t config_magic; /*!< Configuration magic value */
221230
} esp_bt_controller_config_t;
222231

223232

@@ -263,10 +272,14 @@ typedef struct {
263272
.main_xtal_freq = CONFIG_XTAL_FREQ, \
264273
.cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, \
265274
.ignore_wl_for_direct_adv = 0, \
266-
.enable_pcl = 0, \
275+
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
267276
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
268277
.enable_csr = 0, \
269278
.ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
279+
.ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
280+
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
281+
.ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
282+
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
270283
.config_magic = CONFIG_MAGIC, \
271284
}
272285

0 commit comments

Comments
 (0)