Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why restarting Bluetooth is not possible after memory release ? #8219

Unanswered
dharmikP17 asked this question in Q&A
Discussion options

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 ?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /