hi ,
I have two separated issues ,note that I'm using last commit for the library:
1- First issues that sometime BLE scan get Stuck and don't report the result any more and only work if I restart the ESP32 any one has any idea why this problem appear ?
2- second problem is kind of weird one if I use setAdvertisedDeviceCallbacks method and make wantDuplicates parameter false (default) when I restart the esp sometime it's hang on boot and code didn't start at all ### I solve this problem temporally by disable all interrupts before restarting but I want to know the real cause of the problem , but when I put wantDuplicates parameter true then esp restart normally .
note that I use ESP32-WROOM-32E and I have very reliable power supply , and here part of code that I use for BLE scanning (I use ESP freeRTOS and this Task run separately on Core 1 with stack size 5000) :
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
BLEDevice::setPower(ESP_PWR_LVL_P7);
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), true);
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
pBLEScan->setMaxResults(0);
if (millis() >= (6006 + TimerCountDown)) {
while (pBLEScan->isScanning()) delay(1);
TimerCountDown = millis();
BLEUpdater();
}
hi , I have two separated issues ,note that I'm using last commit for the library: 1- First issues that sometime BLE scan get Stuck and don't report the result any more and only work if I restart the ESP32 any one has any idea why this problem appear ? 2- second problem is kind of weird one if I use setAdvertisedDeviceCallbacks method and make wantDuplicates parameter false (default) when I restart the esp sometime it's hang on boot and code didn't start at all ### I solve this problem temporally by disable all interrupts before restarting but I want to know the real cause of the problem , but when I put wantDuplicates parameter true then esp restart normally .
note that I use ESP32-WROOM-32E and I have very reliable power supply , and here part of code that I use for BLE scanning (I use ESP freeRTOS and this Task run separately on Core 1 with stack size 5000) :
BLEDevice::init(""); pBLEScan = BLEDevice::getScan(); //create new scan BLEDevice::setPower(ESP_PWR_LVL_P7); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), true); pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster pBLEScan->setInterval(100); pBLEScan->setWindow(99); // less or equal setInterval value pBLEScan->setMaxResults(0);
======================= void BLEUpdater() { Serial.println("Scan started!"); BLEScanResults foundDevices = pBLEScan->start(6, false); //BLEScanResults foundDevices = pBLEScan->getResults(1, false); Serial.print("Devices found: "); Serial.println(foundDevices.getCount()); Serial.println("Scan done!"); pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory pBLEScan->stop(); }