-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Receive "scan_evt timeout" on serial monitor #5860
Comments
Hi! +1, same here, has anyone found any solution to this? I've tried v2.0.2 and can still reproduce it. Thanks in advance! |
same meet this issues after updating to esp32-arduino v2.0.2 |
Tried using ESP-IDF v4.3.1 sdk (without the arduino layer) and still able to reproduce it, looks like an ESP-IDF problem with VHCI. espressif/esp-idf#4001 Anyway, has anyone found any way to handle the error? It's logged in the serial output, but I haven't found any callbacks or events that can be used to restart if "scan_evt timeout" occurs. |
i had the same "scan_evt timeout" issue, been scratching my head for the past 2 weeks. did anyone managed to find a fix? |
currently i am testing adding a delay of 10ms before "pBLEScan->clearResults();" - suspect clearResults happens too fast while callback function is still retrieving data. not sure if this could help... |
i have bad news and good news.
In the above codes, the scanning time is set to 2 seconds and scan interval 10ms, the tested time between each scan is around 2040ms, therefore the TWDT is set to 3 seconds - when scan_evt timeout occures, if hangs for more than 3 seconds, the TWDT will reboot the device.
the entire recovery took about 5s before the ESP32 is up and running again, this walk around is not perfect solution but works for my project. |
Hello@stevenli2020, thanks for giving it a shot. Did you run it on 2.0.3-RC1? |
I have not test it on 2.0.3-RC1, my boards are FireBeetle ESP32. however i believe the TWDT will still be supported on the 2.0.3-RC1, isnt it? |
Still running into this issue tried your fix @stevenli2020 getting error 'scanBLE' was not declared in this scope. |
I’ve been receiving this issue as well - though via h2zero’s amazing NimBLE port for Arduino. The Bluetooth stack stops responding every few hours (though in some cases within 15 minutes, and in others lasting 8 hours+). This is with the latest Arduino framework, built upon esp-idf v4.4.4. |
Implement a BLE scan watchdog to bypass the problem related to the BLE scan hang scan_evt timeout This is a bypass solution to espressif/arduino-esp32#5860 The watchdog will restart the ESP if no new BLE messages has been added to the queue following: checked every 120s if we are after the last BLE message time + the BLE scan interval for passive if the process is not locked by an OTA update or other operation We restart the ESP We also remove the WDT0 enable and disable functions.
Hello, i'm suffering from the same issue, i have set a few debug messages but didnt manage to find exactly when it happens. Sometimes it crashes when bt is connecting, some times when its already connected. Did anyone found a fix? (i've implemented the watchdog and it does help by rebooting the board)
|
I have a work project, so I can't share the code, but I will say that after I went in and removed all my Serial.println statements (because I was done developing/testing that part of the code), I would get the timeout pretty quickly. I had to revert back to the code that had all the print statements, and I haven't seen it since. I will say that I have a task running the BLEScan, and when the results are ready, I suspend the task. The application logic has a conditional to check if the task is suspended:
And after I process the scan results, I call resume on that task, but not before clearing the results:
So it isn't like the results get cleared before being processes. Maybe starting the scan to often doesn't give the internals time? EDIT: I figured it was worth mentioning 'pBLEScan' doesn't have a 'clear' method, it has 'clearResults'. But I pass in a vector to the task:
|
Is there any update here? I also experienced the issue. |
Only thing I can figure so far is application code is not yielding to other processes/tasks and the scan is timing out. Try adding short delay calls to other tasks to allow it to yield, increasing the priority of the scan task, or even add short delays around:
Not sure if it will help, but I can't remember exactly how I got that to work. |
@dpnebert
You can see the whole code here if you want: So I "manually" interrupt the scan and give 2 seconds for the scanner. It is useful for other services too, because otherwise BLE scanner occupies the processor and for example web serving will be very slow. |
I know it might seem like over kill, but here is an example of how I use freeRTOS tasks to allow for adding delays into your code that don't block other parts of your code.
Essentially, the code starts a task that has one job: ble scan. We can add a delay statement in that task to wait X amount of time before starting up again. Two reasons why this is helpful. One, it keeps us from having to keep checking all the time, freeing up those cycles to do other stuff. Two, we can run other tasks while the scan task is delayed. |
@dpnebert |
my older arduino framework didn't have any issues with the scan for ESP32, but after updating the framework this year to latest due to change of PC, i stated to having issues. so i revert back to older framework again last week and so far its been okay. my initial framework espressif32@3.5.0+sha.5fdb90c, i cant be sure since i changed PC and not sure what but i really do hope to find a solution to NimBle library for Scan to be used on newer frameworks. |
Since I've changed the active scan to false, this is not an issue anymore |
This is exactly the problem though -- it breaks when active scanning, and is OK when not active scanning. There are a number of devices that I want to integrate with which require active scanning to work. |
I see, will concurrently run both test and see. |
Implement a BLE scan watchdog to bypass the problem related to the BLE scan hang scan_evt timeout This is a bypass solution to espressif/arduino-esp32#5860 The watchdog will restart the ESP if no new BLE messages has been added to the queue following: checked every 120s if we are after the last BLE message time + the BLE scan interval for passive if the process is not locked by an OTA update or other operation We restart the ESP We also remove the WDT0 enable and disable functions. Former-commit-id: 145cd2b
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. |
Hi guys
I use an ESP32 as scanner and 2 ESP32 Advertised to Scanner
َAfter A few hours I receive a message on serial monitor in scanner device and scanner doesn't work while other peripherals work perfect.
message is "scan_evt timeout"
my code in scanner:
Sketch:
scan time is 3 second.
can you help me?
The text was updated successfully, but these errors were encountered: