New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fastconnect #1342
Comments
https://github.com/tzapu/WiFiManager/commits/feature_fastconnect up to date with master, please test I see no improvement in my env |
Did you already have a connection set up? If so then you first need to erase those connection details otherwise the connection will continue to be made with just ssid and password and will still take longer. Fast connect relies on starting from a fresh connection so that the mac address and channel get persisted on the first Wifi.begin call with mac address and channel included. From then on if any details like mac address or channel change then the fast connect automatically re-persists the new values. |
you don't need a fresh connection, it just sets BSSID and CHANNEL in the config struct void WiFi_print_sta(){
if(wifiIsConnected()){
Serial.println("[WIFI] CONNECTED");
Serial.print("[WIFI] IP: ");
Serial.println(WiFi.localIP());
Serial.print("[WIFI] HOST: ");
Serial.println(getHostname());
Serial.print("[WIFI] BSSID: ");
Serial.println(WiFi.BSSIDstr());
Serial.print("[WIFI] RSSI: ");
Serial.println(WiFi.RSSI());
Serial.print("[WIFI] CHANNEL: ");
Serial.println(WiFi.channel());
} else {
Serial.println("[WIFI] NOT CONNECTED");
}
} |
Maybe I am missing something here, but I thought that if autoconnect is on and the ssid and password have already been persisted from previous software then it will connect using those and therefore never get as far as calling fastconnect scan to get the BSSID and channel. I see a significant decrease in connect time from 3+ seconds to less than 1 second when I use fastconnect. Obviously if BSSID or channel change then the first connect after that is 3+ seconds but then reverts to quick for future connections. I'll run some further tests and also update my copy to be the same as your current fastconnect in case any changes are affecting my results. |
It only gets saved when saving via the web interface, I tried adding an autoupdate, but doing a scan always fails for me after trying to connect, there seems to be some kind of delayed event coming in from the sdk |
Tested with Arduino sketch checking time to first program execution after setup with wifi connected. This sketch could optionally do a config wipe with ESp.eraseConfig(); and WiFi.disconnect(true); FastConnect false 3400mSec FastConnect true 3400mSec (still using basic from ssid and password from before) Connections stay fast from then on. The fastconnect works because a Wifi.begin is done with all parameters BSSID , channel and this is persisted in the native ESP wifi flash configuration. Subsequent calls even with just Wifi,begin and no parameters will still use the BSSID and channel values from the ESP Wifi config. I think that enabling the erase during upload in the Arduino board set up would do the same as my programmatic wipe which would be easier to do. Note I did all this using Arduino 2 but I have had same results using 1.8 in the past. |
Yeah I know how it works, I did the testing for it. Do you have logs? Are you using autoconnect? I have no improvement, I wonder if there is something wrong with the channel here.. They are different *wm:[1] Connecting to NEW AP: MyHotspot
*wm:[1] Using FASTCONNECT NEW
*wm:[2] WiFi Scan SYNC started
*wm:[2] WiFi Scan completed in 4712 ms
*wm:[2] Fast Config RSSI: -36
*wm:[2] Fast Config CHAN: 6
*wm:[2] Fast Config BSSID: 40:16:7E:C3:1E:28
*wm:[1] connectTimeout not set, ESP waitForConnectResult...
*wm:[2] Connection result: WL_CONNECTED
*wm:[1] Connect to new AP [SUCCESS] *wm:[1] Connected in 2207 ms AFTER *wm:[1] Connected in 2208 ms |
Let me try 2.0, pretty sure my esp version is hardcoded to fullscan, also this channel thing is strange.. |
I include here logs. There are two sets here. The first is using the Aug 22 2021 fastconnect code which is what I have been using. This has a set up from erased condition plus a normal restart This shows the connect time of 1 second. The second is from the current github version. This does show a problem with the fastconnect set up. and the connection remains slow. I thought I had tested with this before but I think the IDE didn't recompile and used the older version from the object cache. This time I cleared all caches which does show a problem. |
I have got the current GitHub fastconnect branch to work. In the getFastConConfig the scan and number of networks found is being done by WiFi_scanNetworks(true); and this leads on to a failure to find the network to extract channel and BSSID from. If I replace this by the original direct call WiFi.scanNetworks(); as in Aug 2021 version then it works as intended. I am not sure currently why the WiFi_scanNetworks(true); is not working as there are several different versions of this. Either this needs to be figured out or the direct call used anyway. The getFastConConfig is only used for an initial connection or if channel / BSSID changes so it is not a significant overhead. Edit: Edit2: |
@roberttidey thank you so much for this, I would have never figure this out without more eyes on it. Good catch |
Hi, |
I assume you are using the library branch feature_fastconnect. If so then debug level should default to DEBUG_VERBOSE During the attempt to set up fastconnect you should first see debug messages showing that is scanning networks. One of these should be WiFi Scan ASYNC found: followed by the number of networks found. |
Ill take a look at merging it i |
I just ran a test on a fresh copy of the feature_fastconnect branch and all seemed Ok to me. I tested with a module that previously had been connected under fastconnect and also after I had wiped the config and had to set up via the portal. In both cases connect time after reset was just under 1 second. |
Thanks, yes am using this dev branch. I don't think it's set at Verbose (is the level 3?) so will confirm I have it set. Thanks |
I can confirm my debug level is set at Verbose. Apologies as I hadn't previously clarified my specific issue: I'm getting pretty fast connect times on powerup (1.8s), but unclear if Fast Connect is working as intended because:
My code snippet:
Here's what I'm seeing in log:
Do I need to set another level (DEBUG_DEV or DEBUG_MAX) to see Fast Connect in action? Should I expect to see FastConnect messages here? Thanks |
When fastconnect has been used once then the wifi channel and BSSID are retained by the esp8266 native wifi config and will be used to provide a fast connection irrespective of setting any fastconnect mode. To see the difference you can wipe the config data and then set the wifi parameters via the portal using no fastconnect. The connect times will then be about 3.5 seconds. |
There should be debugging, also I posted debugging code info above, it either outputs bssid stored or not. But i have no idea what esp chip/lib you are using so it could be not working.. not sure. What happens when you save new wifi? |
Just synched from master |
Are there any changes remaining to be done to this branch? I was hoping to use FastConnect for my Deep Sleeping ESP32-S2 project, but as there are ESP32-S2 specific changes in master, I'm worrying about compatibility. Edit: https://github.com/nullstalgia/WiFiManager I did a quick merge, and it seems to work for the moment! Very noticeably faster (most of the time). Hopefully it can get to master soon! |
I will try to look at this in a bit, I am looking over the esp channel scan method and how this will affect that |
Great job, thank you. However does not work on my ESP3266. Connection time after wakeup from deep sleep is 2400-3700ms regardless if fastconnect is true or false. However, with STA IP connection time is 375ms. (Again regardless of fastconnect state.) |
|
I have 3 wemos D1 on my desk, they do all wifi stuff as expected, but fastconnect does not improve connection time. How to test? Pls advise. |
Thats a task for me |
I merged in master to the branch, It seems to work fine for me, I do not really notice any difference with esp8266 though, i always connect under 300ms, and afaik esp8266 does not have a fast scan or channel storage so it can only store bssid_set which in my case didnt do much, maybe cause there is not that many aps around.. not sure.. |
I downloaded the merge. (now default is DEBUG_NOTIFY so I changed to DEBUG_VERBOSE) |
Is bootup faster than wake? Ill add some debug info |
I see no difference. Channel is 4 auth mode WPA2-Personal. |
Revisit this |
I did some testing on v2.0.16-rc.2. in
with
I get around 200ms. |
Yes please :) |
#1114
On save using esp support
store bssid from scan
store channel from scan
On autoconenct if fastconnect and wifi connect fails, recheck fastscan options in case bssid or channel changed
Add getter to determine if fastconenct is saved/set in flash
The text was updated successfully, but these errors were encountered: