alanswx / ESPAsyncWiFiManager

Port WiFiManager to ESP Async Server
MIT License
222 stars 85 forks source link

WM: No saved credentials #15

Open tueddy opened 6 years ago

tueddy commented 6 years ago

Hi,

i try to use your library together with ESPWebserver to replace the sync->async versions. Captive portal works fine, i can connect to my WIFI. But after hard resetting the AP is opened again, message is WM: No saved credentials.

As far as i see WiFi.SSID cannot be read if not connected. Credentials are saved but not accessable if Wifi.begin(); is not yet called.

Problem seems in ESPAsyncWiFiManager.cpp:

AsyncWiFiManager::connectWifi(String ssid, String pass); .. WiFi.SSID() is empty even if a connection was made before reset.

After making this changes the credentials are working fine: before (Line 530): DEBUG_WM("No saved credentials"); after: DEBUG_WM("Try to connect with saved credentials"); WiFi.begin();

I use latest ESP32 aduino github version 20. march 2018 and your library version 0.13

Best regards Dirk

alanswx commented 6 years ago

Does that work? Do you want to patch it? It has been a while since I pulled this together, I am a bit confused about what all the different states are.

tueddy commented 6 years ago

Hi Alan,

yes i've patched and it works (at least for me). Something must have been changed in handling saving ssid/password for arduino ESP-32. regards Dirk

alanswx commented 6 years ago

Can you submit a pull request and I will update it. Please update the version number too.

pa4th commented 6 years ago

Hello all, I patched the ESPAsyncWiFiManager.cpp with

boolean AsyncWiFiManager::autoConnect(char const confName, char const confPassword, char const apName, char const apPassword) { DEBUG_WM(F("")); DEBUG_WM(F("AutoConnect")); String ssid = confName; String pass = confPassword; WiFi.mode(WIFI_STA); if (connectWifi(ssid, confPassword) == WL_CONNECTED) { DEBUG_WM(F("IP Address:")); DEBUG_WM(WiFi.localIP()); //connected return true; } return startConfigPortal(apName, apPassword); }

Now I can use a SSID from a config file

wifiManager.autoConnect(config_WIFISSID, config_WifiPass., "ESP-AP", "123456789");

alanswx commented 6 years ago

Do you want to submit a pull request? Does that fix the other problem as well?

dmytro-nff commented 6 years ago

I confirm the problem ... after hard resetting the AP is opened again... you can check in your example AutoConnectWithFSParametersAndCustomIP.ino

alanswx commented 6 years ago

Can someone submit a fix so I can merge it in? thanks!

debsahu commented 6 years ago

I dont know how to fix this, but what I do is write all WiFi settings to SPIFFs and read it back on startup and do a WiFi.begin with these value before starting AsyncWiFiManager. See: here. But a clear solution on the library front would be ideal. I can create a PR, but don't know what to change to get this to save after successful connect. If someone knows what to change let me know I will create a PR.