Disable Bluetooth error

quanvuee
Posts: 4
Joined: Tue Dec 05, 2017 4:53 am

Disable Bluetooth error

Postby quanvuee » Tue Dec 05, 2017 5:05 am

Hi everyone.
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;
    }

blekyo
Posts: 10
Joined: Tue Nov 14, 2017 2:15 am

Re: Disable Bluetooth error

Postby blekyo » Fri Dec 15, 2017 10:10 am

Hi quanvuee,
Did you manage to make it work? I've heard that instead of deinit evertything we should just use "esp_bt_controller_disable", it doesn't work for me eitheir. I also tried to execute "ESP.restart();" on the loop (only on a certain condition), but the esp32 restart every seconds. I'm clueless, so if have any idea, would be great.
Cheers

Who is online

Users browsing this forum: No registered users and 4 guests