As the title says... Chat on...

User avatar
By Timmiej93
#78973 I've been having some weird issues in this topic, which I think may have something to do with configuring / connecting wifi.sta.

To clarify, what I'm doing:
I'm connected to my ESPs WiFi (a setup WiFi network), which is in STATIONAP mode. My ESP is hosting a small webserver, which I'm accessing in my browser. In that browser, I enter data for connecting the ESP to my main home WiFi network. When I hit the save button, the data is sent to the ESP, which then uses it in wifi.sta.config() and wifi.sta.connect() to connect to the network. At this point, the ESP is still in STATIONAP mode. However, the webpage in my browser is now completely dead. According to my PC, I'm still connected to the ESPs setup WiFi network, but the page doesn't do anything anymore. Even refreshing the page gives me a ERR_CONNECTION_TIMED_OUT error. If I manually disconnect and reconnect to the ESPs setup WiFi network, the page refreshes perfectly fine again.

What it seems like to me, is that connecting to an AP with wifi.sta.connect() messes with any current wifi.ap connection. Is there any way to prevent wifi.ap connections from being lost when using wifi.sta.connect()?
User avatar
By schufti
#78974 the esp8266 only has one radio, so can only operate on one wifi channel, that might be your problem ...
If it starts up in AP mode on ch A and later connects to your home WiFi network on ch B the ESP-AP now also is on ch B, your previous connections on ch A are lost. Refreshing the network list on your PC should show the changed channel.
User avatar
By Timmiej93
#78977 That indeed seems to be exactly what's going on. I did some testing where I gave the wifi.ap the same channel as my home WiFi network, and it worked flawlessly.

Is there any way around this issue? Obviously I can't set wifi.ap's channel according to the WiFi network I want to connect to, since the AP needs to be up before it knows what it's connecting to.

Edit:
It seems like calling wifi.ap.config() with the previously used ssid and password, and the added channel of the network to connect to, _before_ configuring and connecting wifi.sta does work, for some reason. I'll have to use it a bit to see if it's stable, or if it's hit and miss.