It can even be faster, if I store the last known BSSID and channel.
Then it reconnects in my tests in just around a second.
Turning on WiFi does take time.
Then it still does perform a WiFi scan, which takes 200 msec per channel (12 channels) and then does switch to the right channel and tries to connect.
From cold boot till connected currently takes roughly 4300 msec + the DHCP time.
If I can use the last known BSSID and channel, the time to connect can be cut down with roughly 2700 msec.
DHCP time is also more optimized now.
I added some extra delays, which makes it faster
The problem was that if you tried to do a DHCP request before the unit was connected well, it could lead to timeouts.
So instead of 1 - 3 seconds DHCP it now only takes about 50 msec on my system to do the DHCP.
Connect from cold boot, without available BSSID + channel:
Code: Select all
355 : WIFI : Set WiFi to STA
388 : WIFI : Connecting MikroTik attempt #0
2017 : WD : Uptime 0 ConnectFailures 0 FreeMem 26952 WiFiStatus 6
4342 : WIFI : Connected! AP: MikroTik (B8:69:F4:9F:21:FA) Ch: 7 Duration: 3765 ms
4344 : WIFI : DHCP IP: 192.168.1.96 (ESP-Easy-0) GW: 192.168.1.1 SN: 255.255.255.0 duration: 47 ms
4388 : NTP : NTP replied: delay 20 mSec Accuracy increased by 0.036 seconds
Example of reconnect using BSSID + channel:
Code: Select all
577824 : WIFI : Disconnected! Reason: '(200) Beacon timeout' Connected for 9 m 33 s
577826 : WIFI : Switch off WiFi
579147 : WIFI : Set WiFi to STA
579180 : WIFI : Connecting MikroTik attempt #0
580392 : WIFI : Connected! AP: MikroTik (B8:69:F4:9F:21:FA) Ch: 7 Duration: 1038 ms
580394 : WIFI : DHCP IP: 192.168.1.96 (ESP-Easy-0) GW: 192.168.1.1 SN: 255.255.255.0 duration: 42 ms
585517 : NTP : NTP replied: delay 11 mSec Accuracy increased by 0.167 seconds
585519 : Time adjusted by -16.66 msec. Wander: -0.00 msec/second