mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_ble_some_bugs_20221219_v4.3' into 'release/v4.3'
backport some BLE bugs 20221219 (backport v4.3) See merge request espressif/esp-idf!21716
This commit is contained in:
commit
8cd8ec019c
@ -353,6 +353,22 @@ config BTDM_SCAN_DUPL_CACHE_SIZE
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
||||
config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BTDM_BLE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
config BTDM_BLE_MESH_SCAN_DUPL_EN
|
||||
bool "Special duplicate scan mechanism for BLE Mesh scan"
|
||||
depends on BTDM_BLE_SCAN_DUPL
|
||||
|
@ -305,6 +305,8 @@ static uint8_t coex_schm_curr_period_get_wrapper(void);
|
||||
static void * coex_schm_curr_phase_get_wrapper(void);
|
||||
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary);
|
||||
static int coex_register_wifi_channel_change_callback_wrapper(void *cb);
|
||||
static void bt_controller_deinit_internal(void);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
@ -1317,30 +1319,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
if (s_btdm_slp_tmr != NULL) {
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
#endif
|
||||
if (s_wakeup_req_sem) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
esp_phy_modem_deinit();
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1352,6 +1333,13 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
|
||||
btdm_controller_deinit();
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
@ -1373,11 +1361,16 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
|
||||
s_pm_lock_acquired = false;
|
||||
#endif
|
||||
|
||||
if (s_wakeup_req_sem) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
|
||||
if (osi_funcs_p) {
|
||||
free(osi_funcs_p);
|
||||
osi_funcs_p = NULL;
|
||||
}
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
@ -1387,8 +1380,6 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
esp_bt_power_domain_off();
|
||||
|
||||
esp_phy_modem_deinit();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void bt_shutdown(void)
|
||||
|
@ -280,6 +280,22 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
||||
config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BT_CTRL_BLE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
config BT_CTRL_BLE_MESH_SCAN_DUPL_EN
|
||||
bool "Special duplicate scan mechanism for BLE Mesh scan"
|
||||
depends on BT_CTRL_BLE_SCAN_DUPL
|
||||
|
@ -313,6 +313,8 @@ static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end);
|
||||
|
||||
static void bt_controller_deinit_internal(void);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
@ -1272,31 +1274,36 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_deinit(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btdm_controller_deinit();
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable();
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
}
|
||||
|
||||
do {
|
||||
// deinit low power control resources
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) {
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
do {
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (s_lp_cntl.mac_bb_pd) {
|
||||
@ -1304,6 +1311,32 @@ error:
|
||||
s_lp_cntl.mac_bb_pd = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
if (s_wakeup_req_sem != NULL) {
|
||||
@ -1331,7 +1364,6 @@ error:
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
|
||||
|
||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||
#endif
|
||||
|
||||
@ -1345,89 +1377,8 @@ error:
|
||||
free(osi_funcs_p);
|
||||
osi_funcs_p = NULL;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_deinit(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btdm_controller_deinit();
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable();
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// deinit low power control resources
|
||||
do {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
btdm_deep_sleep_mem_deinit();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
#endif
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
if (s_lp_cntl.main_xtal_pu) {
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF));
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
|
||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||
#endif
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_mac_bb_pd_mem_deinit();
|
||||
#endif
|
||||
esp_phy_modem_deinit();
|
||||
|
||||
free(osi_funcs_p);
|
||||
osi_funcs_p = NULL;
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit dbaeb136cacf8c7d071f838c1053f90299f57720
|
||||
Subproject commit d4a224c5d682d6b5a76542c6918b6a59dd0b2f8c
|
@ -1 +1 @@
|
||||
Subproject commit 5031203040da20073bb5c9f32f3444333f30dce7
|
||||
Subproject commit 63f8d3aaad4f8352cd64de817986e152b7da16fe
|
@ -979,12 +979,16 @@ menu "BT DEBUG LOG LEVEL"
|
||||
endmenu #BT DEBUG LOG LEVEL
|
||||
|
||||
config BT_ACL_CONNECTIONS
|
||||
int "BT/BLE MAX ACL CONNECTIONS(1~7)"
|
||||
int "BT/BLE MAX ACL CONNECTIONS(1~9)"
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
range 1 7
|
||||
range 1 9
|
||||
default 4
|
||||
help
|
||||
Maximum BT/BLE connection count
|
||||
Maximum BT/BLE connection count. The ESP32-C3/S3 chip supports a maximum of 10 instances,
|
||||
including ADV, SCAN and connections. The ESP32-C3/S3 chip can connect up to 9 devices if
|
||||
ADV or SCAN uses only one. If ADV and SCAN are both used, The ESP32-C3/S3 chip is connected
|
||||
to a maximum of 8 devices. Because Bluetooth cannot reclaim used instances once ADV or SCAN
|
||||
is used.
|
||||
|
||||
config BT_MULTI_CONNECTION_ENBALE
|
||||
bool "Enable BLE multi-conections"
|
||||
|
@ -1152,7 +1152,7 @@ typedef union {
|
||||
} tBTA_DM_MSG;
|
||||
|
||||
|
||||
#define BTA_DM_NUM_PEER_DEVICE 7
|
||||
#define BTA_DM_NUM_PEER_DEVICE MAX_ACL_CONNECTIONS
|
||||
|
||||
#define BTA_DM_NOT_CONNECTED 0
|
||||
#define BTA_DM_CONNECTED 1
|
||||
|
@ -317,7 +317,7 @@ typedef struct {
|
||||
} tBTA_GATTC_SERV;
|
||||
|
||||
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
||||
#define BTA_GATTC_NOTIF_REG_MAX 7//15
|
||||
#define BTA_GATTC_NOTIF_REG_MAX BTA_GATTC_CONN_MAX
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
@ -17,7 +17,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200622
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
@ -95,6 +95,12 @@ the adv packet will be discarded until the memory is restored. */
|
||||
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
#define SCAN_DUPL_CACHE_REFRESH_PERIOD CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
#else
|
||||
#define SCAN_DUPL_CACHE_REFRESH_PERIOD 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
|
||||
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE
|
||||
#elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY)
|
||||
@ -146,6 +152,7 @@ the adv packet will be discarded until the memory is restored. */
|
||||
.pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \
|
||||
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
|
||||
.hli = BTDM_CTRL_HLI, \
|
||||
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
|
||||
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
|
||||
}
|
||||
|
||||
@ -188,6 +195,7 @@ typedef struct {
|
||||
uint8_t pcm_role; /*!< PCM role (master & slave)*/
|
||||
uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */
|
||||
bool hli; /*!< Using high level interrupt or not */
|
||||
uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */
|
||||
uint32_t magic; /*!< Magic number */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
|
@ -18,7 +18,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02209230
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02212090
|
||||
|
||||
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
|
||||
#define ESP_BT_HCI_TL_VERSION 0x00010000
|
||||
@ -129,6 +129,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
#define DUPL_SCAN_CACHE_REFRESH_PERIOD 0
|
||||
#else
|
||||
#define DUPL_SCAN_CACHE_REFRESH_PERIOD CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#define BT_CTRL_AGC_RECORRECT_EN CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#else
|
||||
@ -187,6 +193,7 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
.hw_recorrect_en = AGC_RECORRECT_EN, \
|
||||
.cca_thresh = CONFIG_BT_CTRL_HW_CCA_VAL, \
|
||||
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
|
||||
.dup_list_refresh_period = DUPL_SCAN_CACHE_REFRESH_PERIOD, \
|
||||
}
|
||||
|
||||
#else
|
||||
@ -255,6 +262,7 @@ typedef struct {
|
||||
uint8_t hw_recorrect_en;
|
||||
uint8_t cca_thresh; /*!< cca threshold*/
|
||||
uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */
|
||||
uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user