mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/btdm_backport_ble_bugs_21_01_29_v4.2' into 'release/v4.2'
Bugfix/btdm backport ble bugs for v4.2 See merge request espressif/esp-idf!12197
This commit is contained in:
commit
9f3750cee7
@ -138,13 +138,28 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if(!params) {
|
||||
LOG_ERROR("%s,params is NULL", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
if (ESP_BLE_IS_VALID_PARAM(params->min_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
|
||||
ESP_BLE_IS_VALID_PARAM(params->max_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
|
||||
ESP_BLE_IS_VALID_PARAM(params->timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) &&
|
||||
(params->latency <= ESP_BLE_CONN_LATENCY_MAX || params->latency == ESP_BLE_CONN_PARAM_UNDEF) &&
|
||||
((params->timeout * 10) >= ((1 + params->latency) * ((params->max_int * 5) >> 1))) && params->min_int <= params->max_int) {
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
} else {
|
||||
LOG_ERROR("%s,invalid connection params:min_int = %d, max_int = %d, latency = %d, timeout = %d",\
|
||||
__func__, params->min_int, params->max_int, params->latency, params->timeout);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length)
|
||||
|
@ -70,7 +70,7 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
||||
|
||||
#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 500 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ /* relate to ESP_BLE_CONN_PARAM_UNDEF in stack/btm_ble_api.h */
|
||||
|
@ -2663,9 +2663,7 @@ void BTA_VendorCleanup (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cmn_ble_vsc_cb.adv_inst_max > 0) {
|
||||
btm_ble_multi_adv_cleanup();
|
||||
}
|
||||
btm_ble_multi_adv_cleanup();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -68,6 +68,8 @@ static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
|
||||
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data);
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
|
||||
|
||||
extern void btc_gattc_congest_callback(tBTA_GATTC *param);
|
||||
|
||||
static const tGATT_CBACK bta_gattc_cl_cback = {
|
||||
bta_gattc_conn_cback,
|
||||
bta_gattc_cmpl_cback,
|
||||
@ -1157,7 +1159,7 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
read_param.read_multiple.num_handles = p_data->api_read_multi.num_attr;
|
||||
read_param.read_multiple.auth_req = p_data->api_read_multi.auth_req;
|
||||
memcpy(&read_param.read_multiple.handles, p_data->api_read_multi.handles,
|
||||
sizeof(UINT16) * p_data->api_read_multi.num_attr);
|
||||
sizeof(UINT16) * p_data->api_read_multi.num_attr);
|
||||
|
||||
status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_MULTIPLE, &read_param);
|
||||
}
|
||||
@ -2164,17 +2166,10 @@ static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
|
||||
********************************************************************************/
|
||||
static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb;
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) != NULL) {
|
||||
if (p_clcb->p_rcb->p_cback) {
|
||||
cb_data.congest.conn_id = conn_id;
|
||||
cb_data.congest.congested = congested;
|
||||
|
||||
(*p_clcb->p_rcb->p_cback)(BTA_GATTC_CONGEST_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
cb_data.congest.conn_id = conn_id;
|
||||
cb_data.congest.congested = congested;
|
||||
btc_gattc_congest_callback(&cb_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -1011,4 +1011,16 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
btc_gattc_free_req_data(msg);
|
||||
}
|
||||
|
||||
void btc_gattc_congest_callback(tBTA_GATTC *param)
|
||||
{
|
||||
esp_ble_gattc_cb_param_t esp_param = {0};
|
||||
memset(&esp_param, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
|
||||
uint8_t gattc_if = BTC_GATT_GET_GATT_IF(param->congest.conn_id);
|
||||
esp_param.congest.conn_id = BTC_GATT_GET_CONN_ID(param->congest.conn_id);
|
||||
esp_param.congest.congested = (param->congest.congested == TRUE) ? true : false;
|
||||
btc_gattc_cb_to_app(ESP_GATTC_CONGEST_EVT, gattc_if, &esp_param);
|
||||
|
||||
}
|
||||
|
||||
#endif ///GATTC_INCLUDED == TRUE
|
||||
|
@ -1962,7 +1962,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
* slave or master*/
|
||||
|
||||
/* if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) { */
|
||||
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
|
||||
if (!match && bda_type != BLE_ADDR_PUBLIC && BTM_BLE_IS_RESOLVE_BDA(bda)) {
|
||||
// save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func.
|
||||
temp_enhanced = enhanced;
|
||||
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data);
|
||||
|
@ -285,6 +285,20 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
|
||||
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
|
||||
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
|
||||
|
||||
// look for public address information
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
|
||||
// p_dev_rec is created at bluetooth initialization, p_dev_rec->ble.static_addr maybe be all 0 before pairing
|
||||
if(p_dev_rec && memcmp(invalid_rand_addr_b, p_dev_rec->ble.static_addr, BD_ADDR_LEN) != 0) {
|
||||
memcpy(bd_addr, p_dev_rec->ble.static_addr, BD_ADDR_LEN);
|
||||
addr_type = p_dev_rec->ble.static_addr_type;
|
||||
}
|
||||
|
||||
// white list must be public address or static random address
|
||||
if(addr_type == BLE_ADDR_RANDOM) {
|
||||
/*
|
||||
A static address is a 48-bit randomly generated address and shall meet the following requirements:
|
||||
@ -292,9 +306,6 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
• All bits of the random part of the address shall not be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 0
|
||||
*/
|
||||
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
|
||||
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
|
||||
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
|
||||
invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK;
|
||||
if((bd_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK
|
||||
&& memcmp(invalid_rand_addr_a, bd_addr, BD_ADDR_LEN) != 0
|
||||
@ -309,7 +320,7 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
|
||||
if (to_add && p_cb->white_list_avail_size == 0) {
|
||||
|
@ -2987,7 +2987,7 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
|
||||
{
|
||||
tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
UINT8 *p_cache;
|
||||
UINT8 length;
|
||||
//UINT8 length;
|
||||
|
||||
/* cache adv report/scan response data */
|
||||
if (evt_type != BTM_BLE_SCAN_RSP_EVT) {
|
||||
@ -3008,17 +3008,9 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
|
||||
|
||||
if (data_len > 0) {
|
||||
p_cache = &p_le_inq_cb->adv_data_cache[p_le_inq_cb->adv_len];
|
||||
STREAM_TO_UINT8(length, p);
|
||||
while ( length && ((p_le_inq_cb->adv_len + length + 1) <= BTM_BLE_CACHE_ADV_DATA_MAX)) {
|
||||
/* copy from the length byte & data into cache */
|
||||
memcpy(p_cache, p - 1, length + 1);
|
||||
/* advance the cache pointer past data */
|
||||
p_cache += length + 1;
|
||||
/* increment cache length */
|
||||
p_le_inq_cb->adv_len += length + 1;
|
||||
/* skip the length of data */
|
||||
p += length;
|
||||
STREAM_TO_UINT8(length, p);
|
||||
if((data_len + p_le_inq_cb->adv_len) <= BTM_BLE_CACHE_ADV_DATA_MAX) {
|
||||
memcpy(p_cache, p, data_len);
|
||||
p_le_inq_cb->adv_len += data_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -840,10 +840,14 @@ void btm_ble_multi_adv_cleanup(void)
|
||||
}
|
||||
|
||||
#if BTM_DYNAMIC_MEMORY == TRUE
|
||||
osi_free(btm_multi_adv_cb_ptr);
|
||||
osi_free(btm_multi_adv_idx_q_ptr);
|
||||
btm_multi_adv_cb_ptr = NULL;
|
||||
btm_multi_adv_idx_q_ptr = NULL;
|
||||
if(btm_multi_adv_cb_ptr) {
|
||||
osi_free(btm_multi_adv_cb_ptr);
|
||||
btm_multi_adv_cb_ptr = NULL;
|
||||
}
|
||||
if(btm_multi_adv_idx_q_ptr) {
|
||||
osi_free(btm_multi_adv_idx_q_ptr);
|
||||
btm_multi_adv_idx_q_ptr = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -4567,7 +4567,9 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
|
||||
/* If page was delayed for disc complete, can do it now */
|
||||
btm_cb.discing = FALSE;
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_acl_resubmit_page();
|
||||
#endif
|
||||
|
||||
if (!p_dev_rec) {
|
||||
return;
|
||||
|
@ -263,7 +263,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act)
|
||||
if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED && rt != GATT_CONGESTED)
|
||||
|| (rt != GATT_CMD_STARTED && p_clcb->op_subtype == GATT_WRITE_NO_RSP)) {
|
||||
if (rt != GATT_SUCCESS) {
|
||||
GATT_TRACE_ERROR("gatt_act_write() failed op_code=0x%x rt=%d", op_code, rt);
|
||||
GATT_TRACE_DEBUG("gatt_act_write() failed op_code=0x%x rt=%d", op_code, rt);
|
||||
}
|
||||
gatt_end_operation(p_clcb, rt, NULL);
|
||||
}
|
||||
|
@ -527,6 +527,7 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
|
||||
|
||||
if (ll != 0) {
|
||||
GATT_TRACE_ERROR("max attribute handle reached in ReadMultiple Request.");
|
||||
err = GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (p_tcb->sr_cmd.multi_req.num_handles == 0) {
|
||||
|
@ -129,7 +129,7 @@ typedef UINT8 tBTM_BLE_SFP;
|
||||
#define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF
|
||||
#define BTM_BLE_CONN_INT_MIN 0x0006
|
||||
#define BTM_BLE_CONN_INT_MAX 0x0C80
|
||||
#define BTM_BLE_CONN_LATENCY_MAX 500
|
||||
#define BTM_BLE_CONN_LATENCY_MAX 499
|
||||
#define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
|
||||
#define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
|
||||
#define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||
|
@ -1836,12 +1836,12 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
|
||||
|
||||
// If already congested, do not accept any more packets
|
||||
if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent) {
|
||||
L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested\
|
||||
L2CAP_TRACE_DEBUG ("L2CAP - CID: 0x%04x cannot send, already congested\
|
||||
xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
|
||||
fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
|
||||
p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
|
||||
osi_free(p_buf);
|
||||
return (L2CAP_DW_FAILED);
|
||||
return (L2CAP_DW_CONGESTED);
|
||||
}
|
||||
|
||||
l2c_enqueue_peer_data (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL], p_buf);
|
||||
|
Loading…
Reference in New Issue
Block a user