Merge branch 'bugfix/btdm_blufi_send_longer_custom_data_will_congested_v3.3' into 'release/v3.3'

component/bt: fix Blufi sends longer customer data will will lead congested(backport v3.3)

See merge request espressif/esp-idf!11724
This commit is contained in:
Jiang Jiang Jian
2021-01-05 09:51:39 +08:00

View File

@ -36,6 +36,7 @@
#include "blufi_int.h"
#include "esp_blufi_api.h"
#include "esp_gatt_common_api.h"
#if (GATTS_INCLUDED == TRUE)
@ -456,6 +457,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
}
}
}
void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
{
struct blufi_hdr *hdr = NULL;
@ -526,10 +528,21 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
remain_len -= hdr->data_len;
}
btc_blufi_send_notify((uint8_t *)hdr,
retry:
if (blufi_env.is_connected == false) {
return;
}
if (esp_ble_get_cur_sendable_packets_num(BTC_GATT_GET_CONN_ID(blufi_env.conn_id)) > 0) {
btc_blufi_send_notify((uint8_t *)hdr,
((hdr->fc & BLUFI_FC_CHECK) ?
hdr->data_len + sizeof(struct blufi_hdr) + 2 :
hdr->data_len + sizeof(struct blufi_hdr)));
} else {
BTC_TRACE_WARNING("%s wait to send blufi custom data\n", __func__);
vTaskDelay(pdMS_TO_TICKS(10));
goto retry;
}
osi_free(hdr);
hdr = NULL;