mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-28 19:34:53 +00:00
74d6f1ae81
Example: Update lighting app on ESP32-H2 qrcode: use managed_component instead of the extra_component from IDF
51 lines
1.5 KiB
C++
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;
|
|
}
|