fix(bt): initialize BLE Log in host-only mode

Initialize and deinitialize BLE Log from the Bluedroid host lifecycle when the local
controller is disabled. Guard controller mbuf handling with BLE_LOG_LL_ENABLED so host-
only builds do not depend on controller headers.

Update NimBLE to b6e2f93db269ad2bba8715953cb56f93bae4fc2f to provide the corresponding
host-only initialization. Combine the host initialization fix and the final NimBLE
revision into one prerequisite commit.
This commit is contained in:
Zhou Xiao
2026-09-22 14:46:50 +08:00
committed by guozifan
parent 1a70765bb3
commit f4ec0e19b6
3 changed files with 18 additions and 5 deletions
@@ -13,9 +13,9 @@
#include "ble_log_rt.h"
#include "esp_log.h"
#if CONFIG_SOC_ESP_NIMBLE_CONTROLLER
#if CONFIG_BLE_LOG_LL_ENABLED && CONFIG_SOC_ESP_NIMBLE_CONTROLLER
#include "os/os_mbuf.h"
#endif /* CONFIG_SOC_ESP_NIMBLE_CONTROLLER */
#endif /* CONFIG_BLE_LOG_LL_ENABLED && CONFIG_SOC_ESP_NIMBLE_CONTROLLER */
/* VARIABLE */
#define TAG "ble_log"
@@ -200,13 +200,13 @@ void ble_log_lbm_write_trans(ble_log_prph_trans_t **trans, ble_log_src_t src_cod
BLE_LOG_MEMCPY(buf + BLE_LOG_FRAME_HEAD_LEN, addr, len);
}
if (len_append) {
#if CONFIG_SOC_ESP_NIMBLE_CONTROLLER
#if CONFIG_BLE_LOG_LL_ENABLED && CONFIG_SOC_ESP_NIMBLE_CONTROLLER
if (omdata) {
os_mbuf_copydata((struct os_mbuf *)addr_append, 0,
len_append, buf + BLE_LOG_FRAME_HEAD_LEN + len);
}
else
#endif /* CONFIG_SOC_ESP_NIMBLE_CONTROLLER */
#endif /* CONFIG_BLE_LOG_LL_ENABLED && CONFIG_SOC_ESP_NIMBLE_CONTROLLER */
{
BLE_LOG_MEMCPY(buf + BLE_LOG_FRAME_HEAD_LEN + len, addr_append, len_append);
}
@@ -19,6 +19,9 @@
#include "bt_common.h"
#include "bt_osal.h"
#include "bt_prf_task.h"
#if CONFIG_BLE_LOG_ENABLED && !CONFIG_BT_CONTROLLER_ENABLED
#include "ble_log.h"
#endif
static esp_bluedroid_status_t s_bt_host_state = ESP_BLUEDROID_STATUS_UNINITIALIZED;
@@ -246,6 +249,12 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
}
#endif
#if CONFIG_BLE_LOG_ENABLED && !CONFIG_BT_CONTROLLER_ENABLED
if (!ble_log_init()) {
LOG_WARN("BLE Log init failed");
}
#endif
s_bt_host_state = ESP_BLUEDROID_STATUS_INITIALIZED;
return ESP_OK;
@@ -274,6 +283,10 @@ esp_err_t esp_bluedroid_deinit(void)
return ESP_ERR_NO_MEM;
}
#if CONFIG_BLE_LOG_ENABLED && !CONFIG_BT_CONTROLLER_ENABLED
ble_log_deinit();
#endif
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_MAIN_INIT;
msg.act = BTC_MAIN_ACT_DEINIT;