r-downing / PersWiFiManager

Persistent WiFiManager Arduino library for ESP8266
http://ryandowning.net/PersWiFiManager/
MIT License
111 stars 34 forks source link

EXPERIMENTAL: Access Portal reporting back successful and unsuccessful connections #27

Open Jeroen88 opened 5 years ago

Jeroen88 commented 5 years ago

EXPERIMENTAL features to report back the status of the connection. If e.g. a false password is entered, this is reported back to the portal page, so the user can correct his failure without having to reconnect. Also a successful connection is reported back.

Attention: not tested on an ESP8266 yet, only on a ESP32 (although I do not expect too many issues)

To try this you should:

This will take you to the modfied AP portal.

If this works, comment this line in setup(): persWM.resetSettings(); Beause calling resetSettings() will clear any previously entered WiFi credentials. If you do not call this, the WiFi credentials are saved in non volatile memory. If the library can connect to a previously configured WiFi network it will not show the portal at all!

After a successful connection to a WiFi network is made, the ESP32 / ESP8266 will remain in dual mode (STA and AP). You can close the AP by calling PersWiFiManager::closeAp(), or, from the browser, do a GET at wifi/closeap.

Reporting the status of the WiFi connection back to the browser client is done with a json at wifi/report. This JSON has more data than only the connection status:

{ connection: true or false, SSID: the SSID of the WiFi network the ESP32 / ESP8266 is connected to (if connection == true), APSSID: the SSID of the ESP32 / ESP8266 itself, if in AP mode, IP: the IP address assigned to the ESP32 / ESP8266, if connected to a WiFi network }

Attention: connection: is always present, the other fields may be undefined

I am still somewhat unsatisfied with leaving the AP mode activated after connecting to a WiFi network, but:

Jeroen88 commented 5 years ago

Now the behavior of the client is as follows:

Some other changes: