khoih-prog / ESPAsync_WiFiManager

This is an ESP32 (including ESP32-S2 and ESP32-C3) / ESP8266 WiFi Connection Manager, using ESPAsyncWebServer, with fallback web configuration portal. Use this library for configuring ESP32, ESP8266 modules' WiFi, etc. Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP WiFi channel. With examples supporting ArduinoJson 6.0.0+ as well as 5.13.5- . Using AsyncDNSServer instead of DNSServer now.
MIT License
290 stars 73 forks source link

Let WM wait for connection to succeed #55

Closed Vithop closed 3 years ago

Vithop commented 3 years ago

Added a while loop to check when Wifi Manager connects to internet

khoih-prog commented 3 years ago

Thanks for your PR. But I don't think it's necessary.

The autoconnect() already has the autoconnect waiting loop

while (millis() - startedAt < 10000)
{
  //delay(100);
  delay(200);

  if (WiFi.status() == WL_CONNECTED)
  {
    float waited = (millis() - startedAt);

    LOGWARN1(F("Connected after waiting (s) :"), waited / 1000);
    LOGWARN1(F("Local ip ="), WiFi.localIP());

    return true;
  }
}

also the while forever loop while(WiFi.status() != WL_CONNECTED) is not good as sometimes, the system loop() still needs to run even if no WiFi.

This is the minimal example, just to show how you can minimize an example, and not expected to be used. It;s better to use the full-fledge example for your use cases.

Please don't hesitate to post other PRs if you find out bugs or enhancements. Very good for a undergrad Student as yourself to participate and contribute. Keep up the good work and sure you'll have a great future.

Vithop commented 3 years ago

Thanks for the compliments I look forward to contributing more if I can!