-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Why restarting Bluetooth is not possible after memory release ? #8219
-
I was actually facing issue while trying to restart the Bluetooth module in ESP32. I have to do this because I want to use Wi-Fi as well.
When I went into library there were few mentions that restart will not work after memory release.
if (is_start_disabled){
ESP_LOGE(BT_AV_TAG, "re-start not supported after end(true)");
return;
}
In end process the function for releasing memory is
if (release_memory) {
ESP_LOGI(BT_AV_TAG,"disable bluetooth");
if (esp_bluedroid_disable() != ESP_OK){
ESP_LOGE(BT_AV_TAG,"Failed to disable bluetooth");
}
log_free_heap();
ESP_LOGI(BT_AV_TAG,"deinit bluetooth");
if (esp_bluedroid_deinit() != ESP_OK){
ESP_LOGE(BT_AV_TAG,"Failed to deinit bluetooth");
}
log_free_heap();
ESP_LOGI(BT_AV_TAG,"esp_bt_controller_disable");
if (esp_bt_controller_disable()!=ESP_OK){
ESP_LOGE(BT_AV_TAG,"esp_bt_controller_disable failed");
}
log_free_heap();
// waiting for status change
while(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED)
delay(50);
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED){
ESP_LOGI(BT_AV_TAG,"esp_bt_controller_deinit");
if (esp_bt_controller_deinit()!= ESP_OK){
ESP_LOGE(BT_AV_TAG,"esp_bt_controller_deinit failed");
}
log_free_heap();
}
// after a release memory - a restart will not be possible
ESP_LOGI(BT_AV_TAG,"esp_bt_controller_mem_release");
if (esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)!= ESP_OK){
ESP_LOGE(BT_AV_TAG,"esp_bt_controller_mem_release failed");
}
log_free_heap();
is_start_disabled = true;
}
Here also I see comment that restart will not be possible. This is the A2DP library and I have witnessed same thing with BLE too.
Why is that ? And if I want to start Bluetooth again, restarting ESP is the only option ? if yes why ?
Second thing is there are several deinit methods in above function. What if I took them outside and leave only memory release function in there(after release memory comment part). Will Wi-Fi work then without releasing memory ?
However, in Bluetooth Serial this is not the case, I can end and begin process again without any issue. Again but in Bluetooth Serial end method runs all deinit methods shown above except memory release. So I think it does not need particular mechanics that are necessary for a2dp and BLE, Am I right ?
Beta Was this translation helpful? Give feedback.