Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

AutoConnectWithFSParametersAndCustomIP.ino forgets reverts to AP after power cycle #543

Closed
heldopsokken opened this issue Mar 2, 2018 · 21 comments
Labels
bug Validated BUG
Milestone

Comments

@heldopsokken
Copy link

Hardware

WiFimanager Branch/Release: 0.12
Hardware: wemos d1 mini
Core Version: 2.4.0, staging

Description

If i use the example AutoConnectWithFSParametersAndCustomIP.ino it reverts to AP mode after a power cycle. Is this by design or am i missing something?
The custom parameters are retrieved successfully from the SPIFFS

@tablatronix
Copy link
Collaborator

tablatronix commented Mar 2, 2018

esp8266 or esp32?
development branch?

@heldopsokken
Copy link
Author

esp8266, on wemos d1 mini.
using version 0.12 in arduino ide. Arduino ide version: 1.8.5

After setting the settings the JSON is succesfully written and can be read again on reboot, however if I remove the power and start the ESP again it powers up the AP again and seems to have forgotten its SSID and password.

Tried on multiple modules with the same result.

@tablatronix
Copy link
Collaborator

no idea, try development version, lots of bugs were fixed

@heldopsokken
Copy link
Author

heldopsokken commented Mar 2, 2018

tried development version. Looks totally different, but result is the same.

*WM: No saved credentials, skipping wifi *WM: Connection result: WL_NO_SSID_AVAIL *WM: lastconxresult: WL_NO_SSID_AVAIL

@tablatronix
Copy link
Collaborator

sometimes config wont save if memory is corrupt, you could try erasing flash with esptool.

@heldopsokken
Copy link
Author

Thanks for your help. This did the trick indeed. Would love if this would be implemented inside the arduino IDE..

I do love the Wifimanager library!

@tablatronix
Copy link
Collaborator

I think there is a nodemcu flasher that has a ui that will erase also

@heldopsokken
Copy link
Author

heldopsokken commented Mar 4, 2018

@tablatronix Thanks for the hint. I know the program. I guess I prefer the commandline tool instead. Works a lot better.

I found another issue with the WifiManager Development branch.
After saving settings it does not save the settings to spiffs.
Somehow saveconfig callback is not being set by wifimanager.

This does work in the Master branch build but there i am running into other issues.

See what happens with the development branch
*WM: Sent wifi save page *WM: Connecting to a new AP *WM: Connecting as wifi client... *WM: wifi station disconnect *WM: Connecting to new AP *WM: enableSTA PERSISTENT ON *WM: connectTimeout not set, ESP waitForConnectResult... *WM: Connection result: WL_CONNECTED *WM: lastconxresult: WL_CONNECTED *WM: Connect to new AP [SUCCESS] *WM: Got IP Address: *WM: 192.168.2.44 *WM: disconnect configportal *WM: config portal exiting

With the Master branch the SPIFFS file is being written, see below

*WM: WiFi save *WM: Parameter *WM: server *WM: mqtt.local *WM: Parameter *WM: port *WM: 8080 *WM: Parameter *WM: blynk *WM: <REMOVED> *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 3 Should save config connected...yeey :) saving config { "mqtt_server": "mqtt.local", "mqtt_port": "8080", "blynk_token": "<REMOVED>", "ip": "192.168.2.44", "gateway": "192.168.2.254", "subnet": "255.255.255.0" }local ip
Any idea what is causing this to happen with the development build?

As mentioned earlier with with post I cannot use the master build since this does not keep wifi credentials after a power cycle. With the development branch the custom parameters are not being saved to SPIFFS after submitting values.

Thanks again for your help!

@tablatronix
Copy link
Collaborator

The master should not also have that bug. Odd.
Ill test this, i have not yet tested hooks

@tablatronix
Copy link
Collaborator

I see
callback is only called on failure and if setBreakAfterConfig true.
Ill fix tomorrow if its a bug

tablatronix added a commit that referenced this issue Mar 6, 2018
@tablatronix
Copy link
Collaborator

tablatronix commented Mar 6, 2018

ok fixed the callback, it should be called like it was before, on save and if _shouldBreakAfterConfig , on failure

@heldopsokken
Copy link
Author

Thanks! @tablatronix, This fixes the saving to SPIFFS indeed.

However I do still run into the following:
After configuring the AP via wifimanager it connects to wifi and runs the code successfully.
When i reset the device via the resetbutton it also returns to the previous configured AP.
However. If i unplug the device and leave it unpowered for several minutes and power it up again it looses the configured wifi settings and starts wifimanager again.

I guess this is not expected behavior? I tested it with several modules and cleaned the flash with esptool before.

When flashing the wifi credentials in the code this does not happen with the modules, so I am ruling out the flash to be worn out with these modules.

@tablatronix
Copy link
Collaborator

tablatronix commented Mar 6, 2018

suggestions

add a 3 second delay at setup, WiFi.printDiag(Serial), and see what it outputs, see if your credentials are there first.

What if you unplug, replug and reset ? Could be a wifi startup race condition

@tablatronix
Copy link
Collaborator

If you still can reproduce, create a new issue for this

@tablatronix tablatronix added the bug Validated BUG label Mar 6, 2018
@tablatronix tablatronix added this to the dev milestone Mar 6, 2018
@heldopsokken
Copy link
Author

Hi,
thanks for your answer.
with a 5 seconds delay at startup the microcontroller does not forget the stored access point.

@tablatronix
Copy link
Collaborator

That is odd, it should not take that long to startup wifi and it should happen before setup

@tablatronix
Copy link
Collaborator

do you have a simple sketch ?
Does it happen with autoconnect example?

@heldopsokken
Copy link
Author

I will check this weekend. My sketch is based on the example sketch with custom variables. My hunch is that it is this combination which is causing this behavior.

@tablatronix
Copy link
Collaborator

Are you using static ip?

@heldopsokken
Copy link
Author

Hi, Sorry for the large delay. Was a bit occupied last weeks. I do not use static IP.

@tablatronix
Copy link
Collaborator

Can you create a new issue for this particular issue with code if you have

isots-code added a commit to isots-code/WiFiManager that referenced this issue May 31, 2018
* update library.properties

* clean up parameters

* oops

* clean up .h file

* fix tabs

* fix up parameters

* fixup debugging

* fixes paramid issues

paramid must be alphanumeric and adds {I} token support to use ids as input names if we make that optional.

* debugging clean

* oops

* adds exit to readme

* moved http strings to include, added token flags

* typo

* cleanup

* moved all html strings out of code

* more string tokens

* fix paramscount, oops

* doh...

* tzapu#454 adds WIFI_MANAGER_OVERRIDE_STRINGS

I dont feel like resolving conflicts

* fixup merge

* ajax test

* Bug fix for problem discovered when setting length to 1 for additional parameters

The initialization of the buffer holding the value stopped before the last character and storage did not take into account the extra-byte for end of string.

* debugsoftapconfig for esp32

* make debug funcs public

* fix esp32 examples

* fix esp32 wifi.ssid

* Update README.md

Esp32 warning

* camelcase _staShowStaticFields

* readme

* adds webclient checking for timeout delay

* remove reset, no reason for it

* converting token strings, in progress broken

* all tokens now in strings

* implemented info strings for esp32

* fix some html bugs

* change uptime

* infohelp align html

* added webserver precompiler warning

updates readme

* readme

* template

* Lower RAM usage of library

Place remaining debug messages into Flash using F().

* Update WiFiManager.cpp

* Update WiFiManager.cpp

* Update WiFiManager.cpp

* Create contributing.md

* Create ISSUE_TEMPLATE.md

* rename

* rename

* fix esp32 esp8266 bug

* moved strings to flash

* refactor ip form outputs

* adds disconnect method for users

non persistent disconnect

* publicized debug helpers

* ugh aliases

* moved all tokens to strings.h

* adds toggle for scan quality as percentage

`setScanDispPerc` until we have decent remplating

* oops

* defaulting to icons

* cleanup

* some more strings in progmem

* fix sketch size

* editing strings

* more strings cleanup

* refix memsketch

* more string cleanup

* left in debug

* comments

* typo

* dup define

* moved _wifissidprefix to progmem

* esp32 strings progmem

* strings

* file headers

* missed one file header

* Update ISSUE_TEMPLATE.md

* Update ISSUE_TEMPLATE.md

* documenting source

* change wifiscan detaisl to css for toggling

* more strings progmem

* oops broke lock icons

* bugged

* tzapu#528 adds getLastConxResult

* gitignore

no gitignore? add more stuff

* fix info page and adds esp32 aphostname

* testing tzapu#527

* fixes tzapu#527

* fix tzapu#527 for esp8266

* adds getWiFiIsSaved()

* doc blocks, reformatting code

* stability tzapu#527

* clean up

* remove debugging

* add result checking tzapu#527

* remove debugging

* change some uneeded ints

* feature tzapu#533 failure details

* allow empty ssids, bail earlier

* template update

* debuggin esp32 auth fail events

* tzapu#528

using a static var for esp32 event for now to get this working and test. Probably not the best, not sure what the best option is here for esp32 onevent static member function callbacks

* tzapu#528 WL_DISCONNECTED support for testing

* tzapu#534

* change webserver pointer to using

* remove warning

* fix some minor warnings

* adding menu control, in progress

* fix bug

* finish up menu customization

* fix template

* add param help

* fix up menus

* fix param crash

* fix menu and param save

* fix resetsettings

* adds mdns support

* change defs

* simplify debug

* comments

* fix menuids

* add wifiscan preloading with cache

This uses core scan object and assumes its lifetime, I am not sure what the scope is or how long it lives, will have to convert to local copy if its being lost, caching for 60s after startweb portal and 10s after root load, refresh bypasses cache

* fix order

* add preloadscan enable

* fix webserver pointer

* comments

* tzapu#542 handler

* tzapu#546 fix?

Since I do not know how to fix the delegated constructors properly, this should fix the issue for now

* oops tzapu#546

* adds erase

* add debugging

* remove dnsserver from readme

* adds nvs erase

// #define WM_ERASE_NVS // esp32 erase() will erase NVS

* oops

* adds opt erase flag

* fix savecallback tzapu#543

* fixup tzapu#548

* fix constructor

* move routes to strings

* oops fix constructor again

* remove preallocation of params memory

* init params as null

I started gettting odd exceptions, so I thought this should be null and not on the stack or pointing to garbage. I might be totally in the wrong here.

* fix customhtml parameters

* remove debug

* fixes tzapu#551

* disable ssid input autoformatting

autocorrect='off' autocapitalize='none'

* remove serial.prints

* fix up connection result for ondemand portal

* fix autoreconnect on auth failure

* notes

* fixes tzapu#555 oops

* added debug levels

* add esp shields

* Update README.md

* add WM_RTC def for rtc.h

* Added Custom DNS, fix newlines

* fix tabs

* comments

* oops

* remove testing

* minor layout fix to config

* add setShowDnsFields, adds edge case force hide ip fields

* adds section hrs

* showinfoerase toggle

* kludge setmenu with size so it works

Prboably going to add a vector for this, I do not want to add the overhead of std::array for something optional

* debug remove

* menuids as vector to deal with size

This kind of makes it a pain in the ass for users, not sure how to make this easier, I can take in an array of string ids, with a count arg, makes it easier, but then users can pass nonsense in, this way its enum ids, but damn it sure is convoluted. Welcome to ideas here...

```c++
  std::vector<WiFiManager::menu_page_t> menu = {wm.MENU_WIFI,wm.MENU_INFO,wm.MENU_PARAM,wm.MENU_CLOSE,wm.MENU_SEP,wm.MENU_ERASE,wm.MENU_EXIT};
  wm.setMenu(menu);
```

* adds handleClose

* add bug workaround for esp8266 softap

* oops

* fix debug blank

* travis testing

* change setmenu to take vector or array of strnig tokens

* travis testing

* change varnames

* fixing travis

* datatype fixes

* fix section compile error

* fix compiler warnings

* add esp32

* add esp32

* move menutokens

* add esp32

* add esp32

* fix debug levels

* ugh

* add esp32

* add esp32

* add esp32

* add esp32

* add esp32

* make travis build again

* Delete OnDemandConfigPortal.ino.cpp

Sigh

* fix fsparam spiffs examples for esp32

* spiffs case

* refactor connectwifi, adds save timeout

wifi save now no longer uses settimeout timeout

* fixes tzapu#573

* ugh remove test example

* fix parenths tzapu#573

* add setEnableConfigPortal(boolean enable) - if false dont open condig portal from autoConnect()

* getmodestr, handleerase(bool)

* fix handleerase add softapconfig catch fail

* fix nvs erase

* fix erroneous error debug

* adds chip revision efuse

not sure what use this is, as getChipRevision is usually the same anyway... shrug

* clean up defines, removed stuff for memory

* workaround for esp32 webserver parsearguments bug

* fixup scnanetworks

* fix some error logging

* fixes tzapu#581

adds htmlentities to ssid outputs, limited replacements for now

* comment

* fix savetimeout, too short, made optional

* fix menu output

removed test menu output, removed ref , not sure why I put that there....

* comments, debugging

* fixing up setmenu docblocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Validated BUG
Projects
None yet
Development

No branches or pull requests

2 participants