component/bt: Modifed the update connection method to fixed the bug of connection parameters not correct.

This commit is contained in:
Yulong 2017-06-19 03:22:25 -04:00
parent f114ef4a6a
commit 01705166bc
3 changed files with 19 additions and 13 deletions

View file

@ -953,6 +953,13 @@
#define BLE_LLT_INCLUDED TRUE
#endif
/* Added this marco to fixed the android 7.0 will lead to update connection parameters
collision when the slave sent the HCI_BLE_UPD_LL_CONN_PARAMS comment to the controller
request the master to update connection parameters directly. */
#ifndef BLE_SLAVE_UPD_CONN_PARAMS
#define BLE_SLAVE_UPD_CONN_PARAMS FALSE
#endif
#ifndef ATT_INCLUDED
#define ATT_INCLUDED TRUE
#endif

View file

@ -122,7 +122,7 @@ BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bda, UINT16 min_int, UINT16 max_in
p_lcb->latency = latency;
p_lcb->timeout = timeout;
p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
btu_start_timer(&p_lcb->upda_con_timer, BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS, L2CAP_UPDATE_CONN_PARAM_TOUT);
l2cble_start_conn_update(p_lcb);
return (TRUE);
@ -464,12 +464,11 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
UINT16 min_conn_int, max_conn_int, slave_latency, supervision_tout;
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
UINT8 status;
btu_start_timer(&p_lcb->upda_con_timer, BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS, L2CAP_UPDATE_CONN_PARAM_TOUT);
if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PENDING) {
if (p_acl_cb != NULL && p_acl_cb->update_conn_param_cb != NULL) {
status = HCI_ERR_ILLEGAL_COMMAND;
L2CAP_TRACE_ERROR("%s, staus = %x", __func__, status);
L2CAP_TRACE_ERROR("%s, staus = %x, line = %d", __func__, status, __LINE__);
btu_stop_timer(&p_lcb->upda_con_timer);
l2c_send_update_conn_params_cb(p_lcb, status);
}
@ -490,7 +489,7 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
/* if both side 4.1, or we are master device, send HCI command */
if (p_lcb->link_role == HCI_ROLE_MASTER
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) && (BLE_SLAVE_UPD_CONN_PARAMS == TRUE)
|| (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
#endif
@ -505,7 +504,7 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
} else {
status = HCI_ERR_ILLEGAL_COMMAND;
L2CAP_TRACE_DEBUG("%s, staus = %x", __func__, status);
L2CAP_TRACE_ERROR("%s, staus = %x, line = %d", __func__, status, __LINE__);
btu_stop_timer(&p_lcb->upda_con_timer);
l2c_send_update_conn_params_cb(p_lcb, status);
return;
@ -515,7 +514,7 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
if (p_lcb->conn_update_mask & L2C_BLE_NEW_CONN_PARAM) {
/* if both side 4.1, or we are master device, send HCI command */
if (p_lcb->link_role == HCI_ROLE_MASTER
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) && (BLE_SLAVE_UPD_CONN_PARAMS == TRUE)
|| (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
#endif
@ -530,10 +529,6 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
p_lcb->conn_update_mask &= ~L2C_BLE_NEW_CONN_PARAM;
p_lcb->conn_update_mask |= L2C_BLE_NOT_DEFAULT_PARAM;
} else {
status = HCI_ERR_ILLEGAL_COMMAND;
L2CAP_TRACE_DEBUG("%s, staus = %x", __func__, status);
btu_stop_timer(&p_lcb->upda_con_timer);
l2c_send_update_conn_params_cb(p_lcb, status);
return;
}
}
@ -555,7 +550,7 @@ void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_in
tL2C_LCB *p_lcb;
L2CAP_TRACE_DEBUG("l2cble_process_conn_update_evt");
L2CAP_TRACE_WARNING("l2cble_process_conn_update_evt: status: %d", status);
/* See if we have a link control block for the remote device */
p_lcb = l2cu_find_lcb_by_handle(handle);
if (!p_lcb) {
@ -563,6 +558,9 @@ void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_in
return;
}
p_lcb->conn_int = conn_interval;
p_lcb->latency = conn_latency;
p_lcb->timeout = conn_timeout;
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
p_lcb->conn_update_mask &= ~L2C_BLE_UPDATE_PENDING;

View file

@ -179,8 +179,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 connetion params status = %d, min_int = %x, max_int = %x,\
conn_int = %d,latency = %d, timeout = %d", param->update_conn_params.status,
ESP_LOGI(GATTS_TAG, "update connetion params status = %d, min_int = %d, max_int = %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,
@ -345,6 +345,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
case ESP_GATTS_CONNECT_EVT: {
esp_ble_conn_update_params_t conn_params = {0};
memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
/* For the IOS system, please reference the apple official documents about the ble connection parameters restrictions. */
conn_params.latency = 0;
conn_params.max_int = 0x50; // max_int = 0x50*1.25ms = 100ms
conn_params.min_int = 0x30; // min_int = 0x30*1.25ms = 60ms