BLEScan crashes whole ESP32 on second call
Posted: Tue Feb 25, 2020 6:47 pm
I make use of following code to scan for Bluetooth-devices:
This code works properly on the very first call (called out of setup()) but when I try to call it the second time some minutes later (this time out of loop() but this does not seem to make a difference), pBLEScan->start() crashes with folowing error message:
Any idea what is wrong and how I can avoid this crash?
Thanks!
Code: Select all
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
if (pBLEScan)
{
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //set passive scan; active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
BLEScanResults foundDevices = pBLEScan->start(5,false);
pBLEScan->stop();
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delete pBLEScan;
pBLEScan=0;
}
BLEDevice::deinit(true);
The whole Bluetooth-stuff is completely initialised and removed on every call due to memory problems - when I do not release this stuff completely, my application lacks enough memory./home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceive)- assert failed!
Any idea what is wrong and how I can avoid this crash?
Thanks!