Skip to content

Commit 3c6236d

Browse files
feat(ble): add channel assessment and enhanced connect function on ESP32-C5
1 parent 8eb5c15 commit 3c6236d

File tree

3 files changed

+101
-2
lines changed

3 files changed

+101
-2
lines changed

components/bt/controller/esp32c5/Kconfig.in

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ config BT_LE_USE_ESP_TIMER
495495
help
496496
Set this option to use Esp Timer which has higher priority timer
497497
instead of FreeRTOS timer
498+
498499
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
499500
bool "BLE adv report flow control supported"
500501
default y
@@ -679,3 +680,48 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
679680
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
680681
Because the code is moved to the flash, the execution speed of the code is reduced.
681682
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
683+
684+
menu "BLE disconnects when Instant Passed (0x28) occurs"
685+
config BT_LE_CTRL_LLCP_CONN_UPDATE
686+
bool "BLE ACL connection update procedure"
687+
default n
688+
help
689+
If this option is enabled, Controller will terminate the connection
690+
when Instant Passed (0x28) error occurs during connection update procedure.
691+
692+
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
693+
bool "BLE ACL channel map update procedure"
694+
default n
695+
help
696+
If this option is enabled, Controller will terminate the connection
697+
when Instant Passed (0x28) error occurs in channel map update procedure.
698+
699+
config BT_LE_CTRL_LLCP_PHY_UPDATE
700+
bool "BLE ACL PHY update procedure"
701+
default n
702+
help
703+
If this option is enabled, Controller will terminate the connection
704+
when Instant Passed (0x28) error occurs in PHY update procedure.
705+
endmenu
706+
707+
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
708+
int "The value of upperlimitmax during scan backoff procedure"
709+
range 1 256
710+
default 32
711+
help
712+
The value of upperlimitmax needs to be a power of 2.
713+
714+
config BT_LE_CTRL_CHAN_ASS_EN
715+
bool "Enable channel assessment"
716+
default n
717+
help
718+
If this option is enabled, The Controller will records the communication quality
719+
for each channel and then start a timer to check and update the channel map every 4 seconds.
720+
721+
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
722+
bool "Enable aux packet when ext adv data length is zero"
723+
default y
724+
help
725+
When this option is enabled, auxiliary packets will be present in the events of
726+
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
727+
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.

components/bt/controller/esp32c5/esp_bt_cfg.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/esp32c5/include/esp_bt.h

Lines changed: 17 additions & 2 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
*/
@@ -159,7 +159,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
159159
*/
160160
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
161161

162-
#define CONFIG_VERSION 0x20241121
162+
#define CONFIG_VERSION 0x20250104
163163
#define CONFIG_MAGIC 0x5A5AA5A5
164164

165165
/**
@@ -215,6 +215,15 @@ typedef struct {
215215
uint8_t csa2_select; /*!< Select CSA#2*/
216216
uint8_t enable_csr; /*!< Enable CSR */
217217
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 */
218+
uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
219+
- The Controller does not disconnect after Instant Passed (0x28) by default. */
220+
uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
221+
uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
222+
- 0 - Disable
223+
- 1 - Enable (default) */
224+
uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
225+
- 0 - Disable (default)
226+
- 1 - Enable */
218227
uint32_t config_magic; /*!< Magic number for configuration validation */
219228
} esp_bt_controller_config_t;
220229

@@ -262,6 +271,12 @@ typedef struct {
262271
.ignore_wl_for_direct_adv = 0, \
263272
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
264273
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
274+
.enable_csr = 0, \
275+
.ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
276+
.ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
277+
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
278+
.ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
279+
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
265280
.config_magic = CONFIG_MAGIC, \
266281
}
267282

0 commit comments

Comments
 (0)