Stop BLE when using WiFi

I'm trying to use BLE and WiFi on ESP32. As I've seen they can't be used at the same time, so I'm trying to figure out a way to stop receiving data from a BLE server. This are the methods to stop BLE that I have tried so far:

btStop(); esp_bt_controller_disable(); esp_bluedroid_disable(); 

However, none seem to work. The ESP32 supposedly connects to WiFi (using WiFiManager), but when I try to connect to Firebase or Twilio the connection is refused. Before trying to connect to Firebase I have 35000 free heap and twilio 80000. So, is there a way to check whether the BLE scan/connection has been stopped? Are there any other commands to turn it off? Could it be that I am running out of heap and I can't connect to Firebase because of that?

4

2 Answers

You're currently missing a couple of deinit calls

esp_bluedroid_disable(); esp_bluedroid_deinit(); //** esp_bt_controller_disable(); esp_bt_controller_deinit(); //** 

You might also have to ensure Wi-Fi hasn't been started while BLE was enabled, you can init, but starting might cause issues where it starts trying to use the radio immediately

If you're using the BLEDevice Library try this:

 BLEDevice::deinit(true); 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like