Merge branch 'bugfix/fix_ble_channel_map_update_v5.3' into 'release/v5.3'

fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(f583012) (v5.3)

See merge request espressif/esp-idf!32581
This commit is contained in:
Island 2024-09-06 10:31:52 +08:00
commit dfbbbabfbc
20 changed files with 156 additions and 72 deletions

View File

@ -118,6 +118,8 @@ do{\
#define OSI_VERSION 0x00010009
#define OSI_MAGIC_VALUE 0xFADEBEAD
#define BLE_PWR_HDL_INVL 0xFFFF
/* Types definition
************************************************************************
*/
@ -254,8 +256,8 @@ extern bool API_vhci_host_check_send_available(void);
extern void API_vhci_host_send_packet(uint8_t *data, uint16_t len);
extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback);
/* TX power */
extern int ble_txpwr_set(int power_type, int power_level);
extern int ble_txpwr_get(int power_type);
extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level);
extern int ble_txpwr_get(int power_type, uint16_t handle);
extern uint16_t l2c_ble_link_get_tx_buf_num(void);
extern void coex_pti_v2(void);
@ -1674,16 +1676,89 @@ esp_bt_controller_status_t esp_bt_controller_get_status(void)
return btdm_controller_status;
}
static int enh_power_type_get(esp_ble_power_type_t power_type)
{
switch (power_type) {
case ESP_BLE_PWR_TYPE_ADV:
return ESP_BLE_ENHANCED_PWR_TYPE_ADV;
case ESP_BLE_PWR_TYPE_SCAN:
return ESP_BLE_ENHANCED_PWR_TYPE_SCAN;
case ESP_BLE_PWR_TYPE_CONN_HDL0:
case ESP_BLE_PWR_TYPE_CONN_HDL1:
case ESP_BLE_PWR_TYPE_CONN_HDL2:
case ESP_BLE_PWR_TYPE_CONN_HDL3:
case ESP_BLE_PWR_TYPE_CONN_HDL4:
case ESP_BLE_PWR_TYPE_CONN_HDL5:
case ESP_BLE_PWR_TYPE_CONN_HDL6:
case ESP_BLE_PWR_TYPE_CONN_HDL7:
case ESP_BLE_PWR_TYPE_CONN_HDL8:
return ESP_BLE_ENHANCED_PWR_TYPE_CONN;
case ESP_BLE_PWR_TYPE_DEFAULT:
return ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT;
default:
break;
}
return power_type;
}
/* extra functions */
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
{
esp_err_t stat = ESP_FAIL;
uint16_t handle = BLE_PWR_HDL_INVL;
int enh_pwr_type = enh_power_type_get(power_type);
if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) {
return ESP_ERR_NOT_SUPPORTED;
}
if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) {
handle = power_type;
}
if (ble_txpwr_set(enh_pwr_type, handle, power_level) == 0) {
stat = ESP_OK;
}
return stat;
}
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
{
esp_power_level_t lvl;
uint16_t handle = BLE_PWR_HDL_INVL;
int enh_pwr_type = enh_power_type_get(power_type);
if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) {
return ESP_PWR_LVL_INVALID;
}
if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) {
handle = power_type;
}
lvl = (esp_power_level_t)ble_txpwr_get(power_type, handle);
return lvl;
}
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle,
esp_power_level_t power_level)
{
esp_err_t stat = ESP_FAIL;
switch (power_type) {
case ESP_BLE_PWR_TYPE_ADV:
case ESP_BLE_PWR_TYPE_SCAN:
case ESP_BLE_PWR_TYPE_DEFAULT:
if (ble_txpwr_set(power_type, power_level) == 0) {
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
if (ble_txpwr_set(power_type, BLE_PWR_HDL_INVL, power_level) == 0) {
stat = ESP_OK;
}
break;
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
if (ble_txpwr_set(power_type, handle, power_level) == 0) {
stat = ESP_OK;
}
break;
@ -1695,33 +1770,26 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
return stat;
}
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type,
uint16_t handle)
{
esp_power_level_t lvl;
int tx_level = 0;
switch (power_type) {
case ESP_BLE_PWR_TYPE_ADV:
case ESP_BLE_PWR_TYPE_SCAN:
lvl = (esp_power_level_t)ble_txpwr_get(power_type);
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
tx_level = ble_txpwr_get(power_type, BLE_PWR_HDL_INVL);
break;
case ESP_BLE_PWR_TYPE_CONN_HDL0:
case ESP_BLE_PWR_TYPE_CONN_HDL1:
case ESP_BLE_PWR_TYPE_CONN_HDL2:
case ESP_BLE_PWR_TYPE_CONN_HDL3:
case ESP_BLE_PWR_TYPE_CONN_HDL4:
case ESP_BLE_PWR_TYPE_CONN_HDL5:
case ESP_BLE_PWR_TYPE_CONN_HDL6:
case ESP_BLE_PWR_TYPE_CONN_HDL7:
case ESP_BLE_PWR_TYPE_CONN_HDL8:
case ESP_BLE_PWR_TYPE_DEFAULT:
lvl = (esp_power_level_t)ble_txpwr_get(ESP_BLE_PWR_TYPE_DEFAULT);
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
tx_level = ble_txpwr_get(power_type, handle);
break;
default:
lvl = ESP_PWR_LVL_INVALID;
break;
return ESP_PWR_LVL_INVALID;
}
return lvl;
return (esp_power_level_t)tx_level;
}
esp_err_t esp_bt_sleep_enable (void)

@ -1 +1 @@
Subproject commit bfdfe8f851c99ced8316b133b0b15521917ea049
Subproject commit ef1dfc518572e9cda55f13906e32207b40ee280b

View File

@ -631,6 +631,7 @@ typedef struct
{
esp_bd_addr_t bd_addr; /*!< peer address */
esp_ble_bond_key_info_t bond_key; /*!< the bond key information */
esp_ble_addr_type_t bd_addr_type; /*!< peer address type */
} esp_ble_bond_dev_t; /*!< the ble bond device type */
@ -1179,13 +1180,13 @@ typedef union {
struct ble_update_conn_params_evt_param {
esp_bt_status_t status; /*!< Indicate update connection parameters success status */
esp_bd_addr_t bda; /*!< Bluetooth device address */
uint16_t min_int; /*!< Min connection interval */
uint16_t max_int; /*!< Max connection interval */
uint16_t min_int; /*!< Minimum connection interval. If the master initiates the connection parameter update, this value is not applicable for the slave and will be set to zero. */
uint16_t max_int; /*!< Maximum connection interval. If the master initiates the connection parameter update, this value is not applicable for the slave and will be set to zero. */
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
uint16_t conn_int; /*!< Current connection interval */
uint16_t conn_int; /*!< Current connection interval in milliseconds, calculated as N × 1.25 ms */
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */
} update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */
This value is calculated as N × 10 ms */
} update_conn_params; /*!< Event parameter for ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */
/**
* @brief ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT
*/

View File

@ -15,7 +15,7 @@
#if (SMP_INCLUDED == TRUE)
//the maximum nubmer of bonded devices
//the maximum number of bonded devices
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_DEVICE_RECORDS)
static void _btc_storage_save(void)
@ -58,7 +58,7 @@ static void _btc_storage_save(void)
addr_section_count ++;
iter = btc_config_section_next(iter);
}
/*exceeded the maximum nubmer of bonded devices, delete them */
/*exceeded the maximum number of bonded devices, delete them */
if (need_remove_iter) {
while(need_remove_iter != btc_config_section_end()) {
const char *need_remove_section = btc_config_section_name(need_remove_iter);
@ -954,6 +954,7 @@ bt_status_t _btc_storage_in_fetch_bonded_ble_device(const char *remote_bd_addr,
bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev, int dev_num)
{
bt_bdaddr_t bd_addr;
int addr_t;
char buffer[sizeof(tBTM_LE_KEY_VALUE)] = {0};
btc_config_lock();
@ -975,6 +976,14 @@ bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev
string_to_bdaddr(name, &bd_addr);
memcpy(bond_dev->bd_addr, bd_addr.address, sizeof(bt_bdaddr_t));
//get address type
if (_btc_storage_get_remote_addr_type((bt_bdaddr_t *)bond_dev->bd_addr, &addr_t) == BT_STATUS_SUCCESS) {
bond_dev->bd_addr_type = (uint8_t) addr_t;
} else {
// Set an invalid address type
bond_dev->bd_addr_type = 0xFF;
BTC_TRACE_ERROR("%s, %s get address type fail", __func__, name);
}
//resolve the peer device long term key
if (_btc_storage_get_ble_bonding_key(&bd_addr, BTM_LE_KEY_PENC, buffer, sizeof(tBTM_LE_PENC_KEYS)) == BT_STATUS_SUCCESS) {
bond_dev->bond_key.key_mask |= ESP_BLE_ENC_KEY_MASK;

View File

@ -390,6 +390,18 @@ typedef enum {
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
/**
* @brief The enhanced type of which tx power, could set Advertising/Connection/Default and etc.
*/
typedef enum {
ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0,
ESP_BLE_ENHANCED_PWR_TYPE_ADV,
ESP_BLE_ENHANCED_PWR_TYPE_SCAN,
ESP_BLE_ENHANCED_PWR_TYPE_INIT,
ESP_BLE_ENHANCED_PWR_TYPE_CONN,
ESP_BLE_ENHANCED_PWR_TYPE_MAX,
} esp_ble_enhanced_power_type_t;
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
@ -407,6 +419,25 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief ENHANCED API for Setting BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc.
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level);
/**
* @brief ENHANCED API of Getting BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
/**
* @brief Initialize BT controller to allocate task and other resource.
* This function should be called only once, before any other BT functions are called.

View File

@ -175,6 +175,7 @@ r_btdm_task_recycle = 0x40000c1c;
r_hci_register_vendor_desc_tab = 0x40000d9c;
r_ke_task_schedule = 0x40000e80;
r_llc_hci_command_handler = 0x40000ef0;
r_llc_loc_ch_map_proc_continue = 0x40000f5c;
r_llc_loc_con_upd_proc_continue = 0x40000f60;
r_llc_loc_phy_upd_proc_continue = 0x40000f78;
r_llc_rem_con_upd_proc_continue = 0x40000fb4;

View File

@ -934,7 +934,6 @@ r_llc_llcp_send = 0x40000f4c;
r_llc_llcp_state_set = 0x40000f50;
r_llc_llcp_trans_timer_set = 0x40000f54;
r_llc_llcp_tx_check = 0x40000f58;
r_llc_loc_ch_map_proc_continue = 0x40000f5c;
r_llc_loc_con_upd_proc_err_cb = 0x40000f64;
r_llc_loc_dl_upd_proc_continue = 0x40000f68;
r_llc_loc_encrypt_proc_continue = 0x40000f6c;

View File

@ -1184,7 +1184,7 @@ r_llc_llcp_send = 0x40003dc8;
r_llc_llcp_state_set = 0x40003dd4;
r_llc_llcp_trans_timer_set = 0x40003de0;
r_llc_llcp_tx_check = 0x40003dec;
r_llc_loc_ch_map_proc_continue = 0x40003df8;
/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */
r_llc_loc_con_upd_proc_err_cb = 0x40003e10;
r_llc_loc_dl_upd_proc_continue = 0x40003e1c;
r_llc_loc_encrypt_proc_continue = 0x40003e28;

View File

@ -338,10 +338,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
EXAMPLE_DEBUG(EXAMPLE_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
EXAMPLE_DEBUG(EXAMPLE_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -442,10 +442,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
ESP_LOGI(GATTC_TAG, "stop adv successfully");
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTC_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTC_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -264,10 +264,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTS_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTS_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -402,10 +402,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
ESP_LOGI(GATTC_TAG, "stop adv successfully");
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTC_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTC_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -227,10 +227,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTS_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTS_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -649,11 +649,8 @@ The `esp_ble_gap_update_conn_params()` function triggers a GAP event `ESP_GAP_BL
```c
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTS_TAG, "update connection params status = %d, min_int = %d, max_int = %d,
conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTS_TAG, "update connection params status = %d, conn_int = %d,latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -265,10 +265,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTS_TABLE_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTS_TABLE_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -768,10 +768,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
uint8_t adv_name_len = 0;
switch (event) {
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTC_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTC_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -352,10 +352,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
esp_ble_gap_ext_adv_set_params(EXT_ADV_HANDLE, &ext_adv_params_2M);
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(GATTS_TABLE_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(GATTS_TABLE_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -181,10 +181,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(BT_BLE_COEX_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(BT_BLE_COEX_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -246,10 +246,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(COEX_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(COEX_TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);

View File

@ -376,10 +376,8 @@ void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
}
break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
ESP_LOGI(TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
ESP_LOGI(TAG, "update connection params status = %d, conn_int = %d, latency = %d, timeout = %d",
param->update_conn_params.status,
param->update_conn_params.min_int,
param->update_conn_params.max_int,
param->update_conn_params.conn_int,
param->update_conn_params.latency,
param->update_conn_params.timeout);