Merge branch 'bugfix/blufi_add_host_deinit_api_v5.0' into 'release/v5.0'

Blufi: Added an API to stop Bluetooth / Blufi profile (v5.0)

See merge request espressif/esp-idf!20863
pull/10970/head
Jiang Jiang Jian 2022-12-02 20:27:15 +08:00
commit fb1ee6b468
4 zmienionych plików z 59 dodań i 3 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -40,6 +40,7 @@ void esp_blufi_gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *a
/* Initialise gatt server */ /* Initialise gatt server */
int esp_blufi_gatt_svr_init(void); int esp_blufi_gatt_svr_init(void);
void esp_blufi_btc_init(void); void esp_blufi_btc_init(void);
void esp_blufi_btc_deinit(void);
#endif #endif
#ifdef CONFIG_BT_BLUEDROID_ENABLED #ifdef CONFIG_BT_BLUEDROID_ENABLED

Wyświetl plik

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -466,4 +466,8 @@ void esp_blufi_btc_init(void)
assert(rc == 0); assert(rc == 0);
} }
void esp_blufi_btc_deinit(void)
{
btc_deinit();
}
#endif #endif

Wyświetl plik

@ -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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@ -21,3 +21,4 @@ void blufi_security_deinit(void);
int esp_blufi_gap_register_callback(void); int esp_blufi_gap_register_callback(void);
esp_err_t esp_blufi_host_init(void); esp_err_t esp_blufi_host_init(void);
esp_err_t esp_blufi_host_and_cb_init(esp_blufi_callbacks_t *callbacks); esp_err_t esp_blufi_host_and_cb_init(esp_blufi_callbacks_t *callbacks);
esp_err_t esp_blufi_host_deinit(void);

Wyświetl plik

@ -47,6 +47,37 @@ esp_err_t esp_blufi_host_init(void)
} }
esp_err_t esp_blufi_host_deinit(void)
{
int ret;
ret = esp_blufi_profile_deinit();
if(ret != ESP_OK) {
return ret;
}
ret = esp_bluedroid_disable();
if (ret) {
BLUFI_ERROR("%s deinit bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ESP_FAIL;
}
ret = esp_bluedroid_deinit();
if (ret) {
BLUFI_ERROR("%s deinit bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ESP_FAIL;
}
ESP_ERROR_CHECK(esp_bt_controller_disable());
ret = esp_bt_controller_deinit();
if (ret) {
BLUFI_ERROR("%s deinit bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ESP_FAIL;
}
return ESP_OK;
}
esp_err_t esp_blufi_gap_register_callback(void) esp_err_t esp_blufi_gap_register_callback(void)
{ {
int rc; int rc;
@ -161,6 +192,25 @@ esp_err_t esp_blufi_host_init(void)
return ESP_OK; return ESP_OK;
} }
esp_err_t esp_blufi_host_deinit(void)
{
esp_err_t ret = ESP_OK;
ret = esp_blufi_profile_deinit();
if(ret != ESP_OK) {
return ret;
}
esp_blufi_btc_deinit();
ret = nimble_port_stop();
if (ret == 0) {
nimble_port_deinit();
}
return ret;
}
esp_err_t esp_blufi_gap_register_callback(void) esp_err_t esp_blufi_gap_register_callback(void)
{ {
return ESP_OK; return ESP_OK;