From eb304455d5840b35428817844543c6064b185ef9 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Fri, 3 Mar 2023 13:55:49 +0530 Subject: [PATCH] Nimble: Added change to give time to allocate buffers, in case previous allocation fails Closes https://github.com/espressif/esp-idf/issues/10849 --- .../bt/host/nimble/esp-hci/src/esp_nimble_hci.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c index eac28d4abce..1cb06db49d4 100644 --- a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c +++ b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c @@ -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);