feat(bt): Add host-agnostic BT OSAL and shared BLE profile task

- Add bt_osal: event queues, mutexes, semaphores, callouts, etc.
- Add the shared BLE profile task and event queue
- Bring both up and tear them down in the host init/deinit paths
- Add unit tests for the OSAL and the profile task
This commit is contained in:
chenjianhua
2026-08-27 11:33:57 +05:30
committed by Rahul Tank
parent c0168e59bf
commit 59f6ca221b
20 changed files with 3864 additions and 18 deletions
-17
View File
@@ -1406,23 +1406,6 @@ config BT_BLE_RPA_TIMEOUT
This set RPA timeout of Controller and Host.
Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s).
config BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT
bool "Allow BLE connection interval below Bluetooth Core Spec minimum (disable host check)"
depends on BT_BLE_ENABLED
default n
help
When enabled, the Bluedroid host skips the minimum BLE connection
interval validation (Bluetooth Core Spec minimum is 0x0006 / 7.5 ms)
and accepts any non-zero interval value from the application. The
BLE controller then enforces what is actually allowed; how small the
connection interval may be depends on controller capability and its
own configuration, not on this host option text.
End users should NOT set this option directly. In typical IDF builds it
follows the active Controller integration when that Controller supports
this mode; use the Controller's own configuration (menu entries and symbol
names differ by chip) instead of toggling this host symbol manually.
menuconfig BT_BLE_50_FEATURES_SUPPORTED
bool "Enable BLE 5.0 and above features(please disable BLE 4.2 if enable BLE 5.0)"
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
@@ -17,6 +17,8 @@
#include "config/stack_config.h"
#include "hci_log/bt_hci_log.h"
#include "bt_common.h"
#include "bt_osal.h"
#include "bt_prf_task.h"
static esp_bluedroid_status_t s_bt_host_state = ESP_BLUEDROID_STATUS_UNINITIALIZED;
@@ -233,6 +235,17 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
}
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
/* Bring up the host-agnostic bt_osal function table */
bt_osal_freertos_funcs_init();
#if CONFIG_BT_PRF_TASK_ENABLED
/* Start the shared BLE profile task now that the bt_osal table is up, so
* profiles can post work without spawning their own tasks. */
if (bt_prf_task_init() != BT_OSAL_OK) {
LOG_WARN("bt_prf_task_init failed");
}
#endif
s_bt_host_state = ESP_BLUEDROID_STATUS_INITIALIZED;
return ESP_OK;
@@ -289,6 +302,15 @@ esp_err_t esp_bluedroid_deinit(void)
osi_mem_deinit();
#endif
#if CONFIG_BT_PRF_TASK_ENABLED
/* Stop the shared BLE profile task while the bt_osal table is still up,
* symmetrically with the init in esp_bluedroid_init_with_cfg(). */
bt_prf_task_deinit();
#endif
/* Release the bt_osal function table set up in esp_bluedroid_init_with_cfg(). */
bt_osal_freertos_funcs_deinit();
s_bt_host_state = ESP_BLUEDROID_STATUS_UNINITIALIZED;
return ESP_OK;
}