mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1275] resetSettings(); not working #1091
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1091
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nhlives on GitHub (Jul 31, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1275
Basic Infos
Hardware
WiFimanager Branch/Release: Master
Esp8266/Esp32:
Hardware: ESP-12E
Core Version: 2.4.0, staging
Description
Problem description
Settings in IDE
Module: NodeMcu 1,0 (esp-12E module)
Additional libraries:
Sketch
Debug Messages
The resetSettings(); doesn't bring up the AP. I need to cause the AP to start after a successful connect. This did work on platform 2.7.4, I'm on 3.0.2
@tablatronix commented on GitHub (Aug 1, 2021):
What does serial say? Esp32 or 8266?
@tarontop commented on GitHub (Aug 6, 2021):
This works for me
@hungtcs commented on GitHub (Aug 15, 2021):
ESP.eraseConfig();working for me.@radacina commented on GitHub (Dec 23, 2021):
Per ESP8266 SDK doc, the advantage over eraseConfig would be IMHO that the "damage" would be limited to the struct size and address:
@tablatronix commented on GitHub (Dec 24, 2021):
ESP8266 or ESP32?????
@radacina commented on GitHub (Dec 24, 2021):
@tablatronix commented on GitHub (Dec 24, 2021):
I am assuming ( lack of logs ) that erase is failing.
I will do some testing with newer libs
wm.resetsettings does a simple disconnect() which hits the sdk with an empty config struct, so could be bugs there..
wm.erase does a ESP.eraseconfig() with bool return
Ill see if i can add a more reliable method, and add status checking
@tablatronix commented on GitHub (Dec 24, 2021):
Also some of these will fail if sta mode is faulty or not active, which could also be a bug in sdk sometimes setmode fails
@AndyT86 commented on GitHub (Mar 26, 2022):
After reading I think I know, I am expecting resetSettings() be permanent but it is not, thus buggy. Commenting out that code is having entire suite reading back in EEPROM'd SSID/password instead of actually erasing it; while removing comment it is like a Safe Mode to block the EEPROM, the actual erasing is somewhere else; given the intent and name this is buggy to use even though it may be actual intent of the suite in the view of WifiManager team.
@tablatronix commented on GitHub (Mar 26, 2022):
Huh?
@AndyT86 commented on GitHub (Mar 26, 2022):
It's not permanent erasure of configuration data, that's what I mean, all it does to my ESP32 is like someone pressed F8 in Windows bootup. That is not expected, commenting out and it reads back in the data written to somewhere to connect to what was set instead of starting anew.
@tablatronix commented on GitHub (Mar 26, 2022):
It erases the wifi credentials, can you tell me what esp chip and lib ?
@AndyT86 commented on GitHub (Mar 26, 2022):
I figured it "bypass" the Wi-Fi creds no erasure really happened, one could tell since it pre-dots the passcode field and rebooting the ESP reads in the cred prior to these, the chip is ESP32-WROOM-32 on a Wemos D1 R32 board; the one shaped like Uno, since that is one that happens to be compatible here, I have not tried the no frill DevKit board I also have. The core lib is Espressif https://github.com/espressif/arduino-esp32
@tablatronix commented on GitHub (Mar 27, 2022):
Not sure what compatible means, all esp are compatible regardless of what dev board/project.
I don't know what pre dots means, the info page clearly shows wifi information as does the serial output.. It should be fairly clear even by the status at the bottom of the home page...
@tablatronix commented on GitHub (Mar 27, 2022):
works for me just fine...
@tablatronix commented on GitHub (Mar 27, 2022):
Cannot reproduce, unless you can show me what its doing. So you are using git staging esp32? IDF? what?
@AndyT86 commented on GitHub (Mar 27, 2022):
I meant USB chip compatibility, some of them are compatible under Windows while the rest need drivers to do the ISP or FTDI; that's neither here nor there. Forget about "pre-dot" I just meant I can observe visually old data is retained. But as you said, serial log is saying exactly that too. A moment while I gather stuff.
@tablatronix commented on GitHub (Mar 27, 2022):
and tested staging OK
@tablatronix commented on GitHub (Mar 27, 2022):
Ok I see the problem here.
esp32 does nothing if wifi is not enabled, let me see how else I can do this, direct erase etc.
Also getting stuff like ssid fails in the same way even if its set.
This works fine if you set WiFi.mode(STA) in your code, as that starts wifi up
add
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+APand it will work
@AndyT86 commented on GitHub (Mar 27, 2022):
I think I figure it out, it works before calling autoConnect(), otherwise the serial log says it is working but it would not be after, might as well since no one need to care whether reset is pre or post turning on.
@tablatronix commented on GitHub (Mar 27, 2022):
resetsettings starts sta actually so nm what i said, but there might be a race condition, i will try adding a delay in there to make sure and also add a check to see if it actually suceeds
@tablatronix commented on GitHub (Mar 27, 2022):
hmm i can test that too, I use ondemand button and it usually also works so might be same issue
@AndyT86 commented on GitHub (Mar 27, 2022):
Oh while I got your attention:
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "WiFi.h"
Used: C:\Users\actsa\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
Error compiling for board WEMOS D1 MINI ESP32.
Some #define and #ifndef stuff I suspect.
@tablatronix commented on GitHub (Mar 27, 2022):
No idea, sounds like an arduino issue,
@AndyT86 commented on GitHub (Mar 27, 2022):
I think I have huge IDE issue, don't know where it is wrong it was fine last night.
@diegotam855 commented on GitHub (May 8, 2022):
Hi @tablatronix, I have a similar issue, so as you said the code is working fine with this line in the setup void:
WiFi.mode(WIFI_STA);But it doesn't work when I move it into a IF statment:
I'm trying to get the memory erase when I press a button on sturtup.
Any suggestion?
My hardware is a ESP8266 Wemos D1 mini Pro
@AndyT86 commented on GitHub (May 8, 2022):
If I may interject, I believe I can be of some help instead of @tablatronix on this, Shawn once said there maybe a bug and I am getting around this at startup differently:

This I am using ESP32, I have both DevKit and Wemos Mini version but shouldn't matter.
@diegotam855 commented on GitHub (May 8, 2022):
Thank you for answering!
But it seams that wifimanager doesn't have
.erase();function, what's that?As a work around I called
.startConfigPortal();with the button without erasing the old credentials.@diegotam855 commented on GitHub (May 8, 2022):
Here is what I'm doing now
@AndyT86 commented on GitHub (May 8, 2022):
No it's not like that, check mine; it just flows into no branching is needed besides that if button ... little detour.
@tablatronix commented on GitHub (May 9, 2022):
No idea it always erases for me.. what esp version?
@tom-ch1 commented on GitHub (Nov 14, 2022):
do we actually know what the various wm functions are supposed to do? I did not find a documentation of resetSettings() nor erase() :-(
@tablatronix commented on GitHub (Nov 14, 2022):
lol, seriously
https://github.com/tzapu/WiFiManager/wiki/API-reference
@Brian-Kristiansen commented on GitHub (Mar 31, 2023):
Hi -
Sorry to revive this old issue...
I ran into the same problem as he original poster, today - trying to use resetSettings() to clear WiFi credentials on a ESP8266 (Wemos D1 mini). I use the library tzapu/WiFiManager@^0.16.0.
When using resetSettings() right before autoConnect() it correctly starts the 192.168.4.1 website etc.. but when using resetSettings() to only clear the credentials, and then immediately restart the board without calling resetSettings(), the previous WiFi credentials are loaded and used by autoConnect(). It looks like the resetSettings() didn't save/clear. Even calling WiFi.disconnect(true) didn't clear the credentials.
I suspected, maybe it tried to clear the EEPROM information, but was now allowed/ignored. So I tried:
This was a succes - setting WiFi.peristent(true) works for me!!
Looks like the WiFi library defaults to WiFi.persistent(false) - so the resetSettings() never persists the clearing. - OR my cheap ESP8266 board does not follow standards .. or ..
Anyway - I hope my tip can help somebody else in the same situation.
@tablatronix - Would it be risky to add a WiFi.persistent(true) in the resetSettings() code?
@tablatronix commented on GitHub (Mar 31, 2023):
Not sure what the problem is
but it already does that in 2.x
@Brian-Kristiansen commented on GitHub (Apr 1, 2023):
Thanks @tablatronix, I see my problem.
I use v0.16.0 - as this is what lib_deps in PlatformIO fetches for me automatically. I cannot see any newer versions there.
In my version of v0.16.0 it looks like this:
.. which corresponds to the log messages I get, when running the application.
Now - how to get PlatformIO to use v2.x? Hmmm.. When will v2.x upgrade from being a RC? ;-)
Thanks.
@tablatronix commented on GitHub (Apr 1, 2023):
You have to use the git address in lib deps
@Suresh6060 commented on GitHub (Aug 17, 2024):
I am also having similar issue on ESP32 dev board. It brings out the AutoConnectAP correctly first time when code is uploaded.
However when attempt is made to bring it up, say for changing the ssid and password (network) , It gets stuck at
wm.setWifiAutoReconnect(false) done
*wm:Disconnecting
wm.disconnectWiFi() done
*wm:resetSettings
*wm:SETTINGS ERASED
w.resetSettings() 2 done
*wm:AutoConnect
*wm:No wifi saved, skipping
*wm:AutoConnect: FAILED for 21 ms
*wm:StartAP with SSID: AutoConnectAP
*wm:AP IP address: 192.168.4.1
*wm:Starting Web Portal
. On the mobile , it shows the autoConnectAP . When trying to connect, it asks for the password too. But it doesn't bring the network assigning page to enter ssis and password. I have tried almost all the methods seen and elsewhere. But the result is same. In some instance it connects to the ESP_XXXXX SSID . Then uploading the code (Practically erases all the saved wifi information ) seems to be the only solution.
what could be the solution ?
@tablatronix commented on GitHub (Aug 17, 2024):
Does it not bring up the captive portal, what if you goto the ip manually in browser?
@Suresh6060 commented on GitHub (Aug 17, 2024):
It doesnt connect. I can see the AutoCoonectAp under the list. However if I click on it, It says ApConnectAP has no internet Tap for options . Looks like it behaves like any other WiFi on the network. The page for entering SSID and PASSWORD doesn't show.
@tablatronix commented on GitHub (Aug 17, 2024):
Thats the captive portal, goto 192.168.4.1 and see if it works,.
@Suresh6060 commented on GitHub (Aug 17, 2024):
I think I got why it behaves like that. I have several other libraries working on connecting to WiFi in the first instance like WebServer.h, HTTPClient.h etc.
They are still connected when wm.resetSettings() is executed and wm.startConfigPortal or autoConnect is tried. This messes with the functionality because the other objects are still latched to the wifi. I don't know how this works out internally.
To confirm this , I used a new sketch with bare minimum code elements to test only WiFiManager. It works nicely every time.
Probably I need to find out how the other objects could be stopped before re-configuring WiFiManager and restarted on successful connection with new WiFi credentials.
Thank you for your time and efforts.
@tablatronix commented on GitHub (Aug 18, 2024):
There is a issue in esp with releasing servers and reusing ports no solution afaik. So you cannot stop and restart another web object as the first iss never actually cleared
@Suresh6060 commented on GitHub (Aug 19, 2024):
I used server.stop()
server is WebServer server(80); declared earlier.
There was another issue.
wm.resetSettings() only cleared the WiFi details stored by WiFiManager wm;
What was stored by WiFi.h still existed.
WiFi.disconnect() only disconnects the network . The information(s) stored earlier still exist. This creates conflicts when wm is re-configured.
In order to synch both WiFi.disconnect(false, true) was used in the begin. This clears the WiFi cache too and wm sends th config with No AP set.
When the new AP is received, both wm and WiFi gets synchronised again and it works.
server.begin() was used to start the server after it was stopped.
Now the whole code works nicely as expected. The only glitch I find is in order to load the in built pages in the server, the esp2 had to reset again soon after config settings. That is fine as of now.
@tablatronix commented on GitHub (Aug 24, 2024):
The credentials are the same as esp, we dont use flash