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.