Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_ble_handle_check' into 'master'
Browse files Browse the repository at this point in the history
fix(ble/bluedroid): Fixed BLE handle check for GATT API

Closes BLERP-1084

See merge request espressif/esp-idf!33900
  • Loading branch information
Isl2017 committed Oct 10, 2024
2 parents ee6742d + 514155d commit 2381487
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions components/bt/host/bluedroid/api/esp_gattc_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,14 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_READ_CHAR;
Expand Down Expand Up @@ -400,10 +404,14 @@ esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (start_handle == 0 || end_handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_READ_BY_TYPE;
Expand Down Expand Up @@ -432,7 +440,7 @@ esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

Expand Down Expand Up @@ -468,7 +476,7 @@ esp_err_t esp_ble_gattc_read_multiple_variable(esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

Expand Down Expand Up @@ -504,10 +512,14 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_READ_CHAR_DESCR;
Expand Down Expand Up @@ -537,10 +549,14 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_WRITE_CHAR;
Expand Down Expand Up @@ -576,10 +592,14 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_WRITE_CHAR_DESCR;
Expand Down Expand Up @@ -615,10 +635,14 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_PREPARE_WRITE;
Expand Down Expand Up @@ -652,10 +676,14 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR;
Expand Down Expand Up @@ -694,6 +722,10 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,

ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_REG_FOR_NOTIFY;
Expand All @@ -712,6 +744,10 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,

ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);

if (handle == 0) {
return ESP_GATT_INVALID_HANDLE;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_UNREG_FOR_NOTIFY;
Expand Down

0 comments on commit 2381487

Please sign in to comment.