Page 1 of 1

(solved) AP Scan before Wifi Connects?

Posted: Wed Aug 26, 2020 2:07 am
by mzimmers
Hi all -

I'm writing an app that wants to do an AP scan *before* acquiring a network. The use model would be that the user performs a scan, chooses the desired AP, and connects.

But, I'm getting the impression that this isn't possible. When I try to start a scan, I get this error:
W (42151) wifi:sta_scan: STA is connecting, scan are not allowed!
Do I correctly infer from this that the Wifi module must already be connected before it can do a scan?

Thanks...

Re: AP Scan before Wifi Connects?

Posted: Fri Sep 04, 2020 9:19 am
by bbulkow
I built the following component which allows you to specify multiple networks. It'll scan, pick the network with the highest signal, and attach first. If the connection drops, it'll rescan. This is the same interface used by the WifiMulti arduino interface.

Perhaps it'll give you a hint as to where you are going wrong....

https://github.com/bbulkow/WiFiMulti-idf

Re: AP Scan before Wifi Connects?

Posted: Fri Sep 04, 2020 2:18 pm
by mzimmers
Hi bbulkow -

Thanks for the response, and the link to the interesting example. It turns out that my problem was a bit more fundamental -- I'm something of a Wifi novice, and whenever I was disconnected, I was calling esp_wifi_stop(). Now I know better.

Your example is very nice; I did learn a few things while reading it. Thanks again.