mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Nimble: Added return value (success / failure ) to nimble_port_init
This commit is contained in:
parent
21b42ce760
commit
2b5f1140dd
@ -1 +1 @@
|
||||
Subproject commit 2412a15acc9cf250f25f541b21ef0edeb1d22fae
|
||||
Subproject commit 76b1f54737b7eba79155c5238a797b8865ce8206
|
@ -35,8 +35,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void nimble_port_init(void);
|
||||
void nimble_port_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief nimble_port_init - Initialize controller and NimBLE host stack
|
||||
*
|
||||
* @return esp_err_t - ESP_OK ( if success)
|
||||
* Error code in case of failure
|
||||
*/
|
||||
esp_err_t nimble_port_init(void);
|
||||
|
||||
/**
|
||||
* @brief nimble_port_deinit - Deinitialize controller and NimBLE host stack
|
||||
*
|
||||
* @return esp_err_t - ESP_OK ( if success)
|
||||
* Error code in case of failure
|
||||
*/
|
||||
esp_err_t nimble_port_deinit(void);
|
||||
|
||||
void nimble_port_run(void);
|
||||
int nimble_port_stop(void);
|
||||
|
@ -484,7 +484,11 @@ 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());
|
||||
|
||||
nimble_port_init();
|
||||
rc = nimble_port_init();
|
||||
if (rc != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to init nimble %d ", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = simple_ble_on_reset;
|
||||
|
@ -132,13 +132,20 @@ void mesh_host_task(void *param)
|
||||
|
||||
esp_err_t bluetooth_init(void)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
mesh_sem = xSemaphoreCreateBinary();
|
||||
if (mesh_sem == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to init nimble %d ", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
||||
|
@ -506,7 +506,9 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
assert(ret == 0);
|
||||
|
||||
/* Configure the host. */
|
||||
ble_hs_cfg.reset_cb = blecent_on_reset;
|
||||
ble_hs_cfg.sync_cb = blecent_on_sync;
|
||||
|
@ -437,7 +437,12 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = bleprph_on_reset;
|
||||
ble_hs_cfg.sync_cb = bleprph_on_sync;
|
||||
|
@ -205,7 +205,13 @@ app_main(void)
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
nimble_port_init();
|
||||
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = periodic_adv_on_reset;
|
||||
ble_hs_cfg.sync_cb = periodic_adv_on_sync;
|
||||
|
@ -184,7 +184,12 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure the host. */
|
||||
ble_hs_cfg.reset_cb = periodic_sync_on_reset;
|
||||
ble_hs_cfg.sync_cb = periodic_sync_on_sync;
|
||||
|
@ -477,7 +477,12 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure the host. */
|
||||
ble_hs_cfg.reset_cb = blecent_on_reset;
|
||||
ble_hs_cfg.sync_cb = blecent_on_sync;
|
||||
|
@ -396,7 +396,12 @@ app_main(void)
|
||||
|
||||
//ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = bleprph_on_reset;
|
||||
ble_hs_cfg.sync_cb = bleprph_on_sync;
|
||||
|
@ -414,7 +414,11 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize UART driver and start uart task */
|
||||
ble_spp_uart_init();
|
||||
|
@ -406,7 +406,11 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize connection_handle array */
|
||||
for (int i = 0; i <= CONFIG_BT_NIMBLE_MAX_CONNECTIONS; i++) {
|
||||
|
@ -615,7 +615,12 @@ static void stack_init_deinit(void)
|
||||
|
||||
ESP_LOGI(tag, "Init host");
|
||||
|
||||
nimble_port_init();
|
||||
rc = nimble_port_init();
|
||||
if (rc != ESP_OK) {
|
||||
ESP_LOGI(tag, "Failed to init nimble %d ", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
nimble_port_freertos_init(blecent_host_task);
|
||||
|
||||
ESP_LOGI(tag, "Waiting for 1 second");
|
||||
@ -635,7 +640,12 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure the host. */
|
||||
ble_hs_cfg.reset_cb = blecent_on_reset;
|
||||
ble_hs_cfg.sync_cb = blecent_on_sync;
|
||||
|
@ -280,7 +280,12 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration */
|
||||
ble_hs_cfg.sync_cb = blehr_on_sync;
|
||||
ble_hs_cfg.reset_cb = blehr_on_reset;
|
||||
|
@ -451,7 +451,11 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ble_svc_gap_init();
|
||||
ble_svc_gatt_init();
|
||||
|
@ -511,7 +511,11 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = bleprph_on_reset;
|
||||
ble_hs_cfg.sync_cb = bleprph_on_sync;
|
||||
|
@ -539,7 +539,11 @@ app_main(void)
|
||||
wifi_init_sta();
|
||||
do_ping_cmd();
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = bleprph_on_reset;
|
||||
ble_hs_cfg.sync_cb = bleprph_on_sync;
|
||||
|
@ -723,7 +723,11 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure the host. */
|
||||
ble_hs_cfg.reset_cb = blecent_on_reset;
|
||||
|
@ -371,7 +371,12 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration */
|
||||
ble_hs_cfg.sync_cb = gatts_on_sync;
|
||||
ble_hs_cfg.reset_cb = gatts_on_reset;
|
||||
|
@ -273,7 +273,7 @@ void app_main(void)
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
#if CONFIG_BT_BLE_ENABLED || CONFIG_BT_NIMBLE_ENABLED
|
||||
esp_ble_helper_init();
|
||||
ESP_ERROR_CHECK(esp_ble_helper_init());
|
||||
#endif
|
||||
|
||||
xTaskCreate(&advanced_ota_example_task, "advanced_ota_example_task", 1024 * 8, NULL, 5, NULL);
|
||||
|
@ -16,13 +16,11 @@
|
||||
#include "bluedroid_gatts.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_BLE_ENABLED
|
||||
static const char *TAG = "BLE_API";
|
||||
#endif
|
||||
|
||||
void esp_ble_helper_init(void)
|
||||
esp_err_t esp_ble_helper_init(void)
|
||||
{
|
||||
esp_err_t err;
|
||||
esp_err_t err = ESP_OK;
|
||||
#if CONFIG_BT_BLE_ENABLED
|
||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||
|
||||
@ -30,48 +28,54 @@ void esp_ble_helper_init(void)
|
||||
err = esp_bt_controller_init(&bt_cfg);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
err = esp_bluedroid_init();
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(err));
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
err = esp_bluedroid_enable();
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(err));
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = esp_ble_gatts_register_callback(gatts_event_handler);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "gatts register error, error code = %x", err);
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
err = esp_ble_gap_register_callback(gap_event_handler);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "gap register error, error code = %x", err);
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
err = esp_ble_gatts_app_register(PROFILE_A_APP_ID);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "gatts app register error, error code = %x", err);
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
esp_err_t local_mtu_err = esp_ble_gatt_set_local_mtu(500);
|
||||
if (local_mtu_err) {
|
||||
ESP_LOGE(TAG, "set local MTU failed, error code = %x", local_mtu_err);
|
||||
return local_mtu_err;
|
||||
}
|
||||
|
||||
#elif CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
nimble_port_init();
|
||||
err = nimble_port_init();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to init nimble %d ", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
ble_hs_cfg.reset_cb = bleprph_on_reset;
|
||||
ble_hs_cfg.sync_cb = bleprph_on_sync;
|
||||
@ -90,6 +94,8 @@ void esp_ble_helper_init(void)
|
||||
nimble_port_freertos_init(bleprph_host_task);
|
||||
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,25 +1,19 @@
|
||||
// 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-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_BLE_ENABLED || CONFIG_BT_NIMBLE_ENABLED
|
||||
void esp_ble_helper_init(void);
|
||||
esp_err_t esp_ble_helper_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1845,7 +1845,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/include/ble_api.h
|
||||
examples/system/ota/native_ota_example/example_test.py
|
||||
examples/system/ota/native_ota_example/main/native_ota_example.c
|
||||
examples/system/ota/otatool/example_test.py
|
||||
|
Loading…
x
Reference in New Issue
Block a user