Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_fast_packets_handling' into 'master'
Browse files Browse the repository at this point in the history
Nimble: Retry buffer allocation, if previous allocation fails

Closes BT-2473 and IDFGH-9487

See merge request espressif/esp-idf!22586
  • Loading branch information
jack0c committed Mar 9, 2023
2 parents da10eff + eb30445 commit e63f609
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c
Expand Up @@ -140,19 +140,23 @@ int ble_hci_trans_reset(void)

static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
{
struct os_mbuf *m;
struct os_mbuf *m = NULL;
int rc;
int sr;
if (len < BLE_HCI_DATA_HDR_SZ || len > MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)) {
return;
}

m = ble_transport_alloc_acl_from_hs();
do {
m = ble_transport_alloc_acl_from_hs();

if (!m) {
ESP_LOGD(TAG,"Failed to allocate buffer, retrying \n");
/* Give some time to free buffer and try again */
vTaskDelay(1);
}
}while(!m);

if (!m) {
ESP_LOGE(TAG, "%s failed to allocate ACL buffers; increase ACL_BUF_COUNT", __func__);
return;
}
if ((rc = os_mbuf_append(m, data, len)) != 0) {
ESP_LOGE(TAG, "%s failed to os_mbuf_append; rc = %d", __func__, rc);
os_mbuf_free_chain(m);
Expand Down

0 comments on commit e63f609

Please sign in to comment.