SanteriLindfors / WiFiProvisioner

An easy-to-use, customizable WiFi provisioning library for ESP32 devices, featuring a modern captive portal and user-friendly interface.
MIT License
13 stars 6 forks source link

Some ESP devices have an issue connecting to dual band routers #1

Open DCStrato opened 9 months ago

DCStrato commented 9 months ago

I found the issue noticed by many that some random number of ESP devices don't connect well to dual band routers. Looping through Wifi.begin() seems to help significantly. I made this code change in two places inside of WiFI Provisioner and have not had a problem since. Moving the Wifi.begin inside of the While not connected loop, before the delay, and timeout check. Save for ConnectToWiFi and connectToExistingWiFINetwork functions.

while (WiFi.status() != WL_CONNECTED) { if (storedPassword.isEmpty()) { WiFi.begin(storedSSID.c_str()); } else { WiFi.begin(storedSSID.c_str(), storedPassword.c_str()); }
delay(wifiDelay); // Check if the connection timeout is reached if (connectionTimeout != 0 && millis() >= startTime) { WiFi.disconnect(); delay(wifiDelay); debugPrintln( "Connection timeout reached, continuing to start the provision"); return false; } }

SanteriLindfors commented 9 months ago

Thank you for the feedback, i can take a look at it to add it to the next release. Also if you're interested, you're welcome to submit a pull request with your proposed changes.