mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
Merge branch 'change/ble_update_lib_20250217' into 'master'
change(ble): [AUTO_MR] 20250217 - Update ESP BLE Controller Lib Closes BLERP-1562 See merge request espressif/esp-idf!37025
This commit is contained in:
commit
6b1d8dbbfb
@ -91,6 +91,7 @@ if(CONFIG_BT_ENABLED)
|
||||
endif()
|
||||
set(ldscripts "linker_esp32c2.lf")
|
||||
else()
|
||||
list(APPEND srcs "controller/${target_name}/ble.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
endif()
|
||||
|
||||
|
@ -283,6 +283,7 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
@ -388,6 +389,15 @@ config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@ -751,14 +761,14 @@ config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero"
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
|
106
components/bt/controller/esp32c5/ble.c
Normal file
106
components/bt/controller/esp32c5/ble.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
12
components/bt/controller/esp32c5/ble_priv.h
Normal file
12
components/bt/controller/esp32c5/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
@ -34,6 +34,7 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@ -111,6 +112,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
@ -945,13 +947,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@ -991,6 +999,7 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
@ -1028,6 +1037,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@ -1081,6 +1091,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@ -1089,6 +1105,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1112,6 +1129,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1621,3 +1639,28 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -315,6 +315,7 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
@ -420,6 +421,15 @@ config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@ -776,14 +786,14 @@ config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero"
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
|
106
components/bt/controller/esp32c6/ble.c
Normal file
106
components/bt/controller/esp32c6/ble.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
12
components/bt/controller/esp32c6/ble_priv.h
Normal file
12
components/bt/controller/esp32c6/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
@ -114,6 +115,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
@ -963,13 +965,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@ -1012,6 +1020,7 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
@ -1049,6 +1058,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@ -1102,6 +1112,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@ -1110,6 +1126,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1133,6 +1150,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1642,3 +1660,28 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -306,6 +306,7 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
@ -411,6 +412,15 @@ config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@ -777,14 +787,14 @@ config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero"
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
|
106
components/bt/controller/esp32h2/ble.c
Normal file
106
components/bt/controller/esp32h2/ble.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
12
components/bt/controller/esp32h2/ble_priv.h
Normal file
12
components/bt/controller/esp32h2/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
@ -34,6 +34,7 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@ -109,6 +110,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
@ -939,13 +941,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@ -988,6 +996,7 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
@ -1023,6 +1032,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@ -1076,6 +1086,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@ -1084,6 +1100,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1107,6 +1124,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1615,3 +1633,28 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 5fedf4bb0e11e11d54d5f712ec17b72cc2c95fdc
|
||||
Subproject commit e17ca05e5e0acf39212811a08174d5c1c69cf165
|
@ -1 +1 @@
|
||||
Subproject commit 4cb60b2cd1c560a85effde18465b0412e715b048
|
||||
Subproject commit 08946905ec0dfcbfc7dd2919b27e43cbcbde66ed
|
@ -1 +1 @@
|
||||
Subproject commit 7d35fc30e8cada9567f97378e24608bc63b080e4
|
||||
Subproject commit e755a655979177c9551d5fb3613ebb4885aab3a5
|
Loading…
x
Reference in New Issue
Block a user