I want to disable BLE affter my function done.
But when I try "esp_bluedroid_disable", It never return and code affter this don't work.
I don't know how and I can't find any example about disable Bluetooth.
Hope someone can help me.
This is my code to disable Bluetooth. It never run to "ESP_LOGI(GATTS_TAG, "esp_bluedroid_disable done");"
Code: Select all
ESP_LOGI(GATTS_TAG, "Stop ble");
esp_err_t ret;
ret = esp_ble_gatts_app_unregister(gl_profile_tab.gatts_if);
if (ret) {
ESP_LOGE(GATTS_TAG, "%s esp_ble_gatts_app_unregister failed\n", __func__);
return;
}
ret = esp_bt_controller_disable();
if (ret) {
ESP_LOGE(GATTS_TAG, "%s esp_bt_controller_disable failed\n", __func__);
return;
}
ESP_LOGI(GATTS_TAG, "esp_bt_controller_deinit");
ret = esp_bt_controller_deinit();
if (ret) {
ESP_LOGE(GATTS_TAG, "%s esp_bt_controller_deinit failed\n", __func__);
return;
}
ESP_LOGI(GATTS_TAG, "esp_bluedroid_disable");
ret = esp_bluedroid_disable();
ESP_LOGI(GATTS_TAG, "esp_bluedroid_disable done");
if (ret) {
ESP_LOGE(GATTS_TAG, " esp_bluedroid_disable failed\n");
return;
}
ESP_LOGI(GATTS_TAG, "esp_bluedroid_deinit");
ret = esp_bluedroid_deinit();
if (ret) {
ESP_LOGE(GATTS_TAG, "%s esp_bluedroid_deinit failed\n", __func__);
return;
}