-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Switching on and off BLE device causing reboot due to memory #7990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@dharmikP17 I'll run some testing using |
Thank you for your time. On thing I noticed is that, If I run only |
@SuGlider Did you get to try ? Let me know if I can try something. I tried
|
I'll work on it along this week. |
Hello, Has anyone found anything related to this ? I waas recently trying A2DP with ESP32 and faced this same issue while switching on and off. Why I am not able to turn off and turn on bluetooth again ? It does work with bluetoothserial though. |
Here is possible trick #include <Arduino.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
bool deviceConnected = false;
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
BLEDevice::startAdvertising();
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
BLEServerCallbacks *cb;
void setup(){
Serial.begin(115200);
cb = new MyServerCallbacks();
}
void loop() {
Serial.println("Start");
BLEDevice::init("ESP32_BLE_2____");
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(cb);
pServer->startAdvertising();
Serial.println("server init");
delay(5000);
BLEDevice::deinit(false);
delete pServer;
Serial.print("free heap : ");
Serial.println(ESP.getFreeHeap());
delay(2000);
Serial.println("End");
} |
As @AAJAY5 hints at the memory loss you are seeing is not due to the deinit and init but to the fact that each time through the loop you are calling Additionally your free heap is still quite high when your app crashes (still over 100k). (StoreProhibited)[https://docs.espressif.com/projects/esp-idf/en/v4.4.3/esp32/api-guides/fatal-errors.html?highlight=storeprohibited#loadprohibited-storeprohibited] doesn't mean you are out of memory. Based on the value of your |
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Board
ESP32
Device Description
ESP32 dev module
Hardware Configuration
No devices connected
Version
v2.0.5
IDE Name
Arduino IDE 2.0.2
Operating System
Windows 10
Flash frequency
80Mhz
PSRAM enabled
no
Upload speed
921600
Description
I want to turn off BLE device for which I am using
BLEDevice::deinit(false);
and then after some work I want to initialize it again and I am usingBLEDevice::init();
for this.Problem is after few iterations it will run out of heap memory and will reboot esp. I am printing free heap on each call and I can see that it is decreasing after every deinit() call. From what I have gathered, If I set free space flag true i.e.
BLEDevice::deinit(true);
then I can never turn on BLE device again and I have tested this too.Is there some configuration I am missing here to reuse this memory ? Is there any other way of doing this ?
My aim is to do http request using wifi after switching off BLE. Can I do that without deinit() method ?
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: