mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
Merge branch 'bugfix/fix_gap_update_conn_params_invalid_arg' into 'master'
fix(ble/bluedroid): return ESP_ERR_INVALID_ARG for invalid conn params Closes BLERP-2915, BLERP-2917, and BLERP-2920 See merge request espressif/esp-idf!49854
This commit is contained in:
@@ -154,7 +154,7 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if(!params) {
|
||||
LOG_ERROR("%s,params is NULL", __func__);
|
||||
return ESP_FAIL;
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (ESP_BLE_IS_VALID_PARAM(params->min_int, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) &&
|
||||
@@ -187,7 +187,7 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
} 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;
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
} else {
|
||||
LOG_ERROR("%s,invalid connection params:min_int = %d, max_int = %d, latency = %d, timeout = %d",\
|
||||
__func__, min_conn_int, max_conn_int, slave_latency, supervision_tout);
|
||||
return ESP_FAIL;
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
@@ -951,7 +951,10 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_WARNING("reg notif: cache not ready, skip check");
|
||||
APPL_TRACE_WARNING("reg notif: cache not ready, skip check, client_if=%d handle=0x%04x bd_addr:%02x:%02x:%02x:%02x:%02x:%02x state=%d",
|
||||
client_if, handle,
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5],
|
||||
p_srcb ? p_srcb->state : 0xff);
|
||||
}
|
||||
|
||||
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL) {
|
||||
|
||||
@@ -147,40 +147,42 @@ BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bda, UINT16 min_int, UINT16 max_in
|
||||
/* See if we have a link control block for the remote device */
|
||||
p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_LE);
|
||||
|
||||
/* If we don't have one, create one and accept the connection. */
|
||||
if (!p_lcb || !p_acl_cb) {
|
||||
L2CAP_TRACE_WARNING ("L2CA_UpdateBleConnParams - unknown BD_ADDR "MACSTR"", MAC2STR(rem_bda));
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (p_lcb->transport != BT_TRANSPORT_LE) {
|
||||
status = HCI_ERR_NO_CONNECTION;
|
||||
need_cb = true;
|
||||
} else if (p_lcb->transport != BT_TRANSPORT_LE) {
|
||||
L2CAP_TRACE_WARNING ("L2CA_UpdateBleConnParams - BD_ADDR "MACSTR" not LE", MAC2STR(rem_bda));
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* Check whether the request conn params is already set */
|
||||
if ((max_int == p_lcb->current_used_conn_interval) && (latency == p_lcb->current_used_conn_latency) &&
|
||||
(timeout == p_lcb->current_used_conn_timeout)) {
|
||||
status = HCI_SUCCESS;
|
||||
status = HCI_ERR_NO_CONNECTION;
|
||||
need_cb = true;
|
||||
L2CAP_TRACE_WARNING("%s connection parameter already set", __func__);
|
||||
}
|
||||
} else {
|
||||
/* Check whether the request conn params is already set */
|
||||
if ((max_int == p_lcb->current_used_conn_interval) && (latency == p_lcb->current_used_conn_latency) &&
|
||||
(timeout == p_lcb->current_used_conn_timeout)) {
|
||||
status = HCI_SUCCESS;
|
||||
need_cb = true;
|
||||
L2CAP_TRACE_WARNING("%s connection parameter already set", __func__);
|
||||
}
|
||||
|
||||
if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PARAM_FULL){
|
||||
status = HCI_ERR_ILLEGAL_COMMAND;
|
||||
need_cb = true;
|
||||
L2CAP_TRACE_ERROR("%s connection parameter update in progress, please try later", __func__);
|
||||
if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PARAM_FULL){
|
||||
status = HCI_ERR_ILLEGAL_COMMAND;
|
||||
need_cb = true;
|
||||
L2CAP_TRACE_ERROR("%s connection parameter update in progress, please try later", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
if (need_cb) {
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.conn_params_update.status = status;
|
||||
memcpy(cb_params.conn_params_update.remote_bd_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
|
||||
memcpy(cb_params.conn_params_update.remote_bd_addr,
|
||||
p_lcb ? p_lcb->remote_bd_addr : rem_bda, BD_ADDR_LEN);
|
||||
cb_params.conn_params_update.min_conn_int = min_int;
|
||||
cb_params.conn_params_update.max_conn_int = max_int;
|
||||
cb_params.conn_params_update.conn_int = p_lcb->current_used_conn_interval;
|
||||
cb_params.conn_params_update.slave_latency = p_lcb->current_used_conn_latency;
|
||||
cb_params.conn_params_update.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
if (p_lcb) {
|
||||
cb_params.conn_params_update.conn_int = p_lcb->current_used_conn_interval;
|
||||
cb_params.conn_params_update.slave_latency = p_lcb->current_used_conn_latency;
|
||||
cb_params.conn_params_update.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
}
|
||||
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_CONNECTION_PARAMS_UPDATE_EVT, &cb_params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user