esp_bluedroid_disable never returns

adam_ohara
Posts: 7
Joined: Thu Jun 07, 2018 2:13 pm

esp_bluedroid_disable never returns

Postby adam_ohara » Thu Mar 07, 2019 5:29 pm

I am working a project that requires enabling the bluetooth module for a short period of time before disabling it again. Enabling the module works fine, but I am having less luck disabling it. It appears that esp_bluedroid_disable never returns. I am using the following code:

Code: Select all

ESP_LOGI(TAG, "Disabling Bluetooth");
if(esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_ENABLED){
    esp_bluedroid_disable();
    while(esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_ENABLED);
}

esp_bluedroid_deinit();
while(esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_UNINITIALIZED);
Any help would be appreciated.

Edit:

I found the problem. I was trying to disable the bluetooth from within a bluetooth callback, so was getting some kind of deadlock. I triggered the disable code on the timer thread to work around this.

MightyMarcus
Posts: 2
Joined: Thu Jan 26, 2023 4:11 pm

Re: esp_bluedroid_disable never returns

Postby MightyMarcus » Thu Jan 26, 2023 5:04 pm

I found the problem. I was trying to disable the bluetooth from within a bluetooth callback, so was getting some kind of deadlock. I triggered the disable code on the timer thread to work around this.
This saved my day! Had the same issue and was stuck for hours.

Went through the hoops of creating a forum acccount here, just to say thank you! :)

Who is online

Users browsing this forum: Baidu [Spider], dzungpv and 83 guests