Closed pcsaito closed 5 years ago
That is strange because if it goes into AP mode, it actually goes into AP+Station mode and continues scanning for configured network. Once it is found, it should shut down AP.
@maximkulkin Hi Maxim,
in essence this was the reason I opened this issue.
By the time I opened that issue, I wasn't aware that esp-wifi-config actually continues trying to reconnect to last known wifi after having launched the AP mode. I believe we can close issue #11 and continue discussion here.
So, after further testing today, I can confirm that the code reconnects to wifi.
However, even if it actually reconnects to the last known wifi, it still keeps announcing the AP SSID. So it somehow is being stacked in AP+Station mode. Furthermore, although connected to the wifi, the accessory looks like "no response" in home app.
I tested the above case using the esp-homekit-demo\examples\sonoff_s20 firmware, which is fairly simple clean code. I powered off both the router and the esp, I plugged in the esp (Wemos D1 mini) and kept the router powered off. Then I started monitoring the serial for a few minutes. The AP was launched very quickly. Then, after 10 minutes I decided it was time to power on the router and make the Wifi network available again. Here is the point where accessory got connected to the Wifi:
no Test1 found, reconnect after 1s
reconnect
no buf for probe, ie len 0
scandone
no Test1 found, reconnect after 1s
reconnect
scandone
scandone
reconnect
scandone
no Test1 found, reconnect after 1s
reconnect
scandone
no Test1 found, reconnect after 1s
reconnect
scandone
scandone
reconnect
scandone
add 0
aid 7
cnt
connected with Test1, channel 3
dhcp client start...
scandone
ip:192.168.179.160,mask:255.255.255.0,gw:192.168.179.1
scandone
scandone
scandone
scandone
scandone
scandone
scandone
scandone
scandone
scandone
`
As I said, the AP kept on and the accessory was not responding at home app.
Should be fixed now with a new WiFi monitoring system.
I have a persistent problem with power failures, my ESP's never recover from them because my router need a lot more time to start than the ESP, so it never connects. I usually have to disarm a circuit breaker to make it connect or do the softAp config again...
I raised the WIFI_CONFIG_CONNECT_TIMEOUT to 300000 and now the router have enough time to return online, I think 15 seconds is not sufficient time to a number of routers to boot up.
What do you think about raising the timeout on the library? The trade-offs will not affect the setup process because as the softAp starts immediately when there is no saved config.