mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 09:02:08 +00:00
feat(bt/bluedroid): Add new version of API for Bluedroid host stack initialization
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "esp_bt.h"
|
||||
#include "osi/future.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "config/stack_config.h"
|
||||
|
||||
static bool bd_already_enable = false;
|
||||
static bool bd_already_init = false;
|
||||
@@ -106,11 +107,22 @@ esp_err_t esp_bluedroid_disable(void)
|
||||
}
|
||||
|
||||
esp_err_t esp_bluedroid_init(void)
|
||||
{
|
||||
esp_bluedroid_config_t cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
return esp_bluedroid_init_with_cfg(&cfg);
|
||||
}
|
||||
|
||||
esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
bt_status_t ret;
|
||||
|
||||
if (!cfg) {
|
||||
LOG_ERROR("%s cfg is NULL", __func__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
LOG_ERROR("Controller not initialised\n");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -125,9 +137,15 @@ esp_err_t esp_bluedroid_init(void)
|
||||
osi_mem_dbg_init();
|
||||
#endif
|
||||
|
||||
ret = bluedriod_config_init(cfg);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid stack initialize fail, ret:%d", ret);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* BTC Init
|
||||
*/
|
||||
* BTC Init
|
||||
*/
|
||||
ret = btc_init();
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid Initialize Fail");
|
||||
@@ -199,6 +217,8 @@ esp_err_t esp_bluedroid_deinit(void)
|
||||
|
||||
btc_deinit();
|
||||
|
||||
bluedriod_config_deinit();
|
||||
|
||||
bd_already_init = false;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
Reference in New Issue
Block a user