esp_bluedroid_disable never returns
Posted: 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:
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.
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);
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.