Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ESP.eraseConfig() does not seem to clear SDK Wifi Credentials #1494

Closed
hallard opened this issue Jan 24, 2016 · 6 comments
Closed

ESP.eraseConfig() does not seem to clear SDK Wifi Credentials #1494

hallard opened this issue Jan 24, 2016 · 6 comments

Comments

@hallard
Copy link
Contributor

hallard commented Jan 24, 2016

Does the ESP.eraseConfig() should also erase SDK Wifi Credentials ?
I've 2 button on my Web Interface to do

  • Reset (just reset the board)
  • Factory Reset to clear all and reset.

Factory Reset restore my default board config settings including clearing my client SSID and PSK, and then call a ESP.eraseConfig()to also clear SDK config. Then issue a normal reset.

Unfortunately, just after Factory Reset, my board reset and then connect to my Old Access point even if I don't call Wifi setting and connection (because my config is empty on those settings, yeah cleared that!!)
Anyone tried this with success ?

@hallard hallard changed the title eraseConfig() does not seems to clear SDK Wifi Credentials ESP.eraseConfig() does not seems to clear SDK Wifi Credentials Jan 24, 2016
@hallard hallard changed the title ESP.eraseConfig() does not seems to clear SDK Wifi Credentials ESP.eraseConfig() does not seem to clear SDK Wifi Credentials Jan 25, 2016
@igrr
Copy link
Member

igrr commented Jan 26, 2016

I think if you do ESP.restart() after ESP.eraseConfig(), SDK libraries will actually restore the configuration from RAM before restarting. I'm not sure this is documented, but I saw this while going through disassembly of some older version of the SDK (1.0.0-like).
You could try to crash instead of calling restart, i.e. do something like *((int*) 0) = 0;. It's not a clean solution, though. I would prefer if the SDK didn't do something under the hood unless instructed to do so explicitly, but well... I guess it's a task for another time.

@hallard
Copy link
Contributor Author

hallard commented Jan 27, 2016

@igrr
you're absolutely right, It did the trick ;-)
I just replaced

*((int*) 0) = 0;

by a watchdog reset, it works but is it correct ?

// Fire Watchdog Reset
while(1);

thanks

@Links2004
Copy link
Collaborator

@hallard
Copy link
Contributor Author

hallard commented Jan 27, 2016

didn't tried that one, it will not restore config like restart() ?

@Links2004
Copy link
Collaborator

yes (last tried on SDK 1.3),
its simple a other way too reset the ESP.
more clean then WDT or triggering a exception.

@electron1979
Copy link

WiFi.disconect() worked for me first go.

ESP.eraseConfig then ESP.reset() OR ESP.eraseConfig() then ESP.restart() did not work for me.
I did not try the ((int) 0) = 0; thing.

The answer to this question was covered here and here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants