Files
esp-matter/examples/common/app_ble/app_ble.cpp
T
WanqQixiang 74d6f1ae81 Submodule: Update the connectedhomeip submodule to the lastest master commit 069b09b5f3
Example: Update lighting app on ESP32-H2

qrcode: use managed_component instead of the extra_component from IDF
2022-08-26 12:02:17 +08:00

51 lines
1.5 KiB
C++

/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
/* It is recommended to copy this code in your example so that you can modify as per your application's needs,
* especially for the indicator calbacks, button_factory_reset_pressed_cb() and button_factory_reset_released_cb().
*/
#include <esp_log.h>
#include <esp_bt.h>
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
#include <esp_nimble_hci.h>
#endif
#include <host/ble_hs.h>
#include <nimble/nimble_port.h>
static const char *TAG = "app_ble";
esp_err_t app_ble_disable()
{
#if CONFIG_BT_NIMBLE_ENABLED && CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE
if (!ble_hs_is_enabled()) {
ESP_LOGI(TAG, "BLE already deinited");
return ESP_OK;
}
int ret = nimble_port_stop();
if (ret != 0) {
ESP_LOGE(TAG, "nimble_port_stop() failed");
return ESP_FAIL;
}
nimble_port_deinit();
esp_err_t err = ESP_OK;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
err = esp_nimble_hci_and_controller_deinit();
#endif
err |= esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err != ESP_OK) {
ESP_LOGE(TAG, "BLE deinit failed");
return ESP_FAIL;
}
ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed");
#endif
return ESP_OK;
}