Merge branch 'bugfix/remove_inappropriate_bluetooth_init_api' into 'master'

Remove unused bluetooth init api

See merge request espressif/esp-idf!18923
This commit is contained in:
Jiang Jiang Jian
2022-07-21 14:53:44 +08:00
22 changed files with 39 additions and 183 deletions

View File

@@ -614,7 +614,7 @@ if(CONFIG_BT_ENABLED)
)
endif()
if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32C3 OR CONFIG_IDF_TARGET_ESP32S3 OR TRUE)
if(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
list(APPEND srcs
"host/nimble/esp-hci/src/esp_nimble_hci.c"
)

View File

@@ -20,7 +20,6 @@
#include "console/console.h"
/*nimBLE Host*/
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"

View File

@@ -628,3 +628,10 @@ config BT_NIMBLE_USE_ESP_TIMER
default y
help
Set this option to use Esp Timer which has higher priority timer instead of FreeRTOS timer
config BT_NIMBLE_LEGACY_VHCI_ENABLE
bool
default y if (IDF_TARGET_ESP32 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
default n
help
This option is used to distinguish whether a previous version of VHCI is being used

View File

@@ -33,46 +33,6 @@ extern "C" {
*/
esp_err_t esp_nimble_hci_init(void);
/**
* @brief Initialize ESP Bluetooth controller(link layer) and VHCI transport
* layer between NimBLE Host and ESP Bluetooth controller
*
* This function initializes ESP controller in BLE only mode and the
* transport buffers to be exchanged between NimBLE host and ESP controller.
* It also registers required host callbacks with the controller.
*
* Below is the sequence of APIs to be called to init/enable NimBLE host and ESP controller:
*
* @code{c}
* void ble_host_task(void *param)
* {
* nimble_port_run(); //This function will return only when nimble_port_stop() is executed.
* nimble_port_freertos_deinit();
* }
*
* int ret = esp_nimble_hci_and_controller_init();
* if (ret != ESP_OK) {
ESP_LOGE(TAG, "esp_nimble_hci_and_controller_init() failed with error: %d", ret);
* return;
* }
*
* nimble_port_init();
*
* //Initialize the NimBLE Host configuration
*
* nimble_port_freertos_init(ble_host_task);
* @endcode
*
* nimble_port_freertos_init() is an optional call that creates a new task in which the NimBLE
* host will run. The task function should have a call to nimble_port_run(). If a separate task
* is not required, calling nimble_port_run() will run the NimBLE host in the current task.
*
* @return
* - ESP_OK if the initialization is successful
* - Appropriate error code from esp_err_t in case of an error
*/
esp_err_t esp_nimble_hci_and_controller_init(void);
/**
* @brief Deinitialize VHCI transport layer between NimBLE Host and
* ESP Bluetooth controller
@@ -85,37 +45,6 @@ esp_err_t esp_nimble_hci_and_controller_init(void);
*/
esp_err_t esp_nimble_hci_deinit(void);
/**
* @brief Deinitialize VHCI transport layer between NimBLE Host and
* ESP Bluetooth controller and disable and deinitialize the controller
*
* @note This function should not be executed in the context of Bluetooth host task.
*
* @note This function should be called after the NimBLE host is deinitialized.
*
* Below is the sequence of APIs to be called to disable/deinit NimBLE host and ESP controller:
*
* @code{c}
* int ret = nimble_port_stop();
* if (ret == 0) {
* nimble_port_deinit();
*
* ret = esp_nimble_hci_and_controller_deinit();
* if (ret != ESP_OK) {
ESP_LOGE(TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
* }
* }
* @endcode
*
* If nimble_port_freertos_init() is used during initialization, then
* nimble_port_freertos_deinit() should be called in the host task after nimble_port_run().
*
* @return
* - ESP_OK if the deinitialization is successful
* - Appropriate error codes from esp_err_t in case of an error
*/
esp_err_t esp_nimble_hci_and_controller_deinit(void);
#ifdef __cplusplus
}
#endif

View File

@@ -20,20 +20,6 @@
#include "esp_compiler.h"
#include "soc/soc_caps.h"
#if SOC_ESP_NIMBLE_CONTROLLER
/* For Chips not using VHCI, these functions return success */
esp_err_t esp_nimble_hci_and_controller_init(void)
{
return ESP_OK;
}
esp_err_t esp_nimble_hci_and_controller_deinit(void)
{
return ESP_OK;
}
#else
#define NIMBLE_VHCI_TIMEOUT_MS 2000
#define BLE_HCI_EVENT_HDR_LEN (2)
#define BLE_HCI_CMD_HDR_LEN (3)
@@ -461,24 +447,6 @@ err:
}
esp_err_t esp_nimble_hci_and_controller_init(void)
{
esp_err_t ret;
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
return ret;
}
if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BLE)) != ESP_OK) {
return ret;
}
return esp_nimble_hci_init();
}
static esp_err_t ble_hci_transport_deinit(void)
{
int ret = 0;
@@ -516,25 +484,3 @@ esp_err_t esp_nimble_hci_deinit(void)
return ESP_OK;
}
esp_err_t esp_nimble_hci_and_controller_deinit(void)
{
int ret;
ret = esp_nimble_hci_deinit();
if (ret != ESP_OK) {
return ret;
}
ret = esp_bt_controller_disable();
if (ret != ESP_OK) {
return ret;
}
ret = esp_bt_controller_deinit();
if (ret != ESP_OK) {
return ret;
}
return ESP_OK;
}
#endif // #if SOC_ESP_NIMBLE_CONTROLLER

View File

@@ -13,7 +13,6 @@
#include "protocomm_priv.h"
/* NimBLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -480,7 +479,6 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg)
int rc;
ESP_LOGD(TAG, "Free memory at start of simple_ble_init %d", esp_get_free_heap_size());
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration. */
@@ -953,10 +951,6 @@ esp_err_t protocomm_ble_stop(protocomm_t *pc)
ret = nimble_port_stop();
if (ret == 0) {
nimble_port_deinit();
ret = esp_nimble_hci_and_controller_deinit();
if (ret != ESP_OK) {
ESP_LOGE(TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
}
}
free_gatt_ble_misc_memory(ble_cfg_p);

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -17,7 +17,6 @@
#endif
#ifdef CONFIG_BT_NIMBLE_ENABLED
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -110,8 +109,13 @@ void bleprph_host_task(void *param)
esp_err_t esp_blufi_host_init(void)
{
ESP_ERROR_CHECK(esp_nimble_hci_init());
nimble_port_init();
esp_err_t err;
err = esp_nimble_init();
if (err) {
BLUFI_ERROR("%s failed: %s\n", __func__, esp_err_to_name(err));
return ESP_FAIL;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = blufi_on_reset;
ble_hs_cfg.sync_cb = blufi_on_sync;
@@ -148,7 +152,11 @@ esp_err_t esp_blufi_host_init(void)
esp_blufi_btc_init();
nimble_port_freertos_init(bleprph_host_task);
err = esp_nimble_enable(bleprph_host_task);
if (err) {
BLUFI_ERROR("%s failed: %s\n", __func__, esp_err_to_name(err));
return ESP_FAIL;
}
return ESP_OK;
}

View File

@@ -0,0 +1,11 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_BLUFI_ENABLE=y
# CONFIG_BT_GATTC_ENABLE is not set
# CONFIG_BT_BLE_SMP_ENABLE is not set
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
CONFIG_MBEDTLS_DHM_C=y

View File

@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,7 +16,6 @@
#endif
#ifdef CONFIG_BT_NIMBLE_ENABLED
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -139,8 +138,6 @@ esp_err_t bluetooth_init(void)
return ESP_FAIL;
}
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = mesh_on_reset;

View File

@@ -7,7 +7,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -423,8 +422,6 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize UART driver and start uart task */

View File

@@ -7,7 +7,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -398,8 +397,6 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize uart driver and start uart task */

View File

@@ -20,7 +20,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -603,8 +602,6 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Configure the host. */
ble_hs_cfg.reset_cb = blecent_on_reset;

View File

@@ -21,7 +21,6 @@
#include "nvs_flash.h"
#include "freertos/FreeRTOSConfig.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -281,8 +280,6 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration */
ble_hs_cfg.sync_cb = blehr_on_sync;

View File

@@ -21,7 +21,6 @@
#include "nvs_flash.h"
#include "freertos/FreeRTOSConfig.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -444,7 +443,6 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
ble_svc_gap_init();

View File

@@ -20,7 +20,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -422,8 +421,6 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;

View File

@@ -18,7 +18,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -539,7 +538,6 @@ app_main(void)
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
wifi_init_sta();
do_ping_cmd();
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration. */

View File

@@ -7,7 +7,6 @@
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -723,7 +722,6 @@ app_main(void)
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();

View File

@@ -8,7 +8,6 @@
#include "nvs_flash.h"
#include "freertos/FreeRTOSConfig.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
@@ -371,7 +370,6 @@ void app_main(void)
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration */

View File

@@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
@@ -79,8 +71,6 @@ void esp_ble_helper_init(void)
#elif CONFIG_BT_NIMBLE_ENABLED
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;

View File

@@ -17,7 +17,6 @@ extern "C" {
#include <stdbool.h>
#include "nimble/ble.h"
#include "modlog/modlog.h"
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"

View File

@@ -1986,7 +1986,6 @@ examples/system/ipc/ipc_isr/main/main.c
examples/system/light_sleep/example_test.py
examples/system/ota/advanced_https_ota/example_test.py
examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c
examples/system/ota/advanced_https_ota/main/ble_helper/ble_api.c
examples/system/ota/advanced_https_ota/main/ble_helper/include/ble_api.h
examples/system/ota/native_ota_example/example_test.py
examples/system/ota/native_ota_example/main/native_ota_example.c