espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.08k stars 7.31k forks source link

First scan in WifiMulti runs synchronously and blocks device for few seconds #1018

Closed 9a4gl closed 4 years ago

9a4gl commented 6 years ago

Hardware:

Board: lolin32 lite Core Installation/update date: ? IDE name: Platform.io Flash Frequency: ? Upload Speed: 115200

Description:

In 9dae9cea373abac265f5ed28210bffaee78c92fd run method has been changed to call WiFi.scanNetworks() instead WiFi.scanComplete()

As scanNetwork is called with any parameter it performs synchronous scanning causing program flow to block for few seconds. As this is called when app starts it cause a lot of problem to other initialization flows, like it disrupts serial communication with my Nextion display, causing some bytes to miss on serial interface.

9a4gl commented 6 years ago

I reverted that patch and everything is working fine. Looks initial problem is fixed and this patch should be reverted.

copercini commented 6 years ago

My tests: reverting WiFi.scanNetworks(); to WiFi.scanComplete(); it's working fine and asynchronously but fully reverting the commit, it stuck =/ so keep status != WL_CONNECTED looks lika a good ideia

What do you think @9a4gl ?

9a4gl commented 6 years ago

Have you traced where and why it get stuck ? I do not remember I had such issues. Currently in my project I am using more customized version of this libarary. I didn't like after Wifi.begin we have loop waiting to get connected. It bloked my app for few seconds each time it get reconnected. I may try to provide you this fully non-blocking version, but I am afraid it is not oneliner.

9a4gl commented 6 years ago

Here is small update after some testing. So, my version which do scan (and connect) asynchronously works fine for first scan, it connects and works. But, if it loose network, new scan does not work, actually it finds something on each cca 20th scan, and then it fails to connect to AP. Looks I will not use MultiWifi :(

docteurzoidberg commented 5 years ago

any update ?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This stale issue has been automatically closed. Thank you for your contributions.