From 8e0cfe7f66d9aa664a758220275b5e1fcccfa904 Mon Sep 17 00:00:00 2001 From: darshan Date: Thu, 10 Aug 2023 15:48:07 +0530 Subject: [PATCH] feat(nimble): Added adv queue congestion check --- components/bt/host/nimble/Kconfig.in | 9 +++++++++ components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c | 8 ++++++++ components/bt/host/nimble/nimble | 2 +- components/bt/host/nimble/port/include/esp_nimble_cfg.h | 8 ++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index 308d5e53be..5d150264f7 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -863,3 +863,12 @@ config BT_NIMBLE_HIGH_DUTY_ADV_ITVL depends on BT_NIMBLE_ENABLED help This enable BLE high duty advertising interval feature + +config BT_NIMBLE_HOST_QUEUE_CONG_CHECK + bool "BLE queue congestion check" + depends on BT_NIMBLE_ENABLED + default n + help + When scanning and scan duplicate is not enabled, if there are a lot of adv packets around + or application layer handling adv packets is slow, it will cause the controller memory + to run out. if enabled, adv packets will be lost when host queue is congested. 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 c165e45ac3..d244f488db 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 @@ -265,6 +265,10 @@ esp_err_t esp_nimble_hci_init(void) xSemaphoreGive(vhci_send_sem); +#if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK) + ble_adv_list_init(); +#endif + return ret; err: ble_buf_free(); @@ -286,5 +290,9 @@ esp_err_t esp_nimble_hci_deinit(void) ble_buf_free(); +#if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK) + ble_adv_list_deinit(); +#endif + return ESP_OK; } diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 37877f9b64..d826fefc3a 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 37877f9b643c03e0ce9e39db4b9301f3a711a1b5 +Subproject commit d826fefc3ad172beb43e4e986575eb132c2c3936 diff --git a/components/bt/host/nimble/port/include/esp_nimble_cfg.h b/components/bt/host/nimble/port/include/esp_nimble_cfg.h index 2c3c6c62a4..4c0650ad6c 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -1738,4 +1738,12 @@ #endif #endif +#ifndef MYNEWT_VAL_BLE_QUEUE_CONG_CHECK +#ifdef CONFIG_BT_NIMBLE_HOST_QUEUE_CONG_CHECK +#define MYNEWT_VAL_BLE_QUEUE_CONG_CHECK CONFIG_BT_NIMBLE_HOST_QUEUE_CONG_CHECK +#else +#define MYNEWT_VAL_BLE_QUEUE_CONG_CHECK FALSE +#endif +#endif + #endif