Skip to content

Commit b9616fd

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

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

components/bt/controller/esp32c6/Kconfig.in

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

components/bt/controller/esp32c6/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/esp32c6/include/esp_bt.h

Lines changed: 19 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
*/
@@ -156,7 +156,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
156156
*/
157157
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
158158

159-
#define CONFIG_VERSION 0x20241121
159+
#define CONFIG_VERSION 0x20250104
160160
#define CONFIG_MAGIC 0x5A5AA5A5
161161

162162
/**
@@ -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

@@ -266,6 +275,10 @@ typedef struct {
266275
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
267276
.enable_csr = 0, \
268277
.ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
278+
.ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
279+
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
280+
.ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
281+
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
269282
.config_magic = CONFIG_MAGIC, \
270283
}
271284
#elif CONFIG_IDF_TARGET_ESP32C61
@@ -315,6 +328,10 @@ typedef struct {
315328
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
316329
.enable_csr = 0, \
317330
.ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
331+
.ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
332+
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
333+
.ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
334+
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
318335
.config_magic = CONFIG_MAGIC, \
319336
}
320337
#endif

0 commit comments

Comments
 (0)