mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1711] WiFi settings are not saved if ESP32 is restarted in SaveConfigCallback #1452
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#1452
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 @rusty-labs on GitHub (Feb 14, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1711
Basic Infos
Hardware
WiFimanager Branch/Release: Master
Esp8266/Esp32:
Hardware: Heltec wifi-lora-32-v3
Core Version: 2.4.0, staging
Description
Steps to reproduce
Settings in IDE
Module: Heltec wifi-lora-32-v3
Sketch
@tablatronix commented on GitHub (Feb 14, 2024):
I suspect breakafterconfig i will test
@rusty-labs commented on GitHub (Feb 14, 2024):
Yeah, if I don't use setBreakAfterConfig my callback is not even called
@rusty-labs commented on GitHub (Feb 15, 2024):
Ok there're multiple issues
Settings are not saved if no successful connection occurred,
So I toggled off
wm.setSaveConnect(false);I assume if user saves settings, settings should be saved no matter what, and connection procedure should be out of this block
Other issue is within the UI
Opening configuration portal second time shows my previously selected SSID in gray color and I assumed I don't need to select it again, so I changed only password.
However on the next bootup SSID is empty while the updated password is there
@rusty-labs commented on GitHub (Feb 15, 2024):
I uploaded the fix addressing UI issue and saving empty ssid
@tablatronix commented on GitHub (Feb 15, 2024):
Yeah there is a other issue about that thanks
Its already saves if its placeholder. I will think of a better way to represent this like disable until clicked or something
@rusty-labs commented on GitHub (Feb 15, 2024):
For the sake of consistency it'd be better to use value instead of a placeholder, since custom parameters are using values
I also checked behavior on my router in client mode, and it also keeps SSID as a value even if it's wrong
@tablatronix commented on GitHub (Feb 15, 2024):
Custom params can also use placeholders.
Connect fails never save but it ahould not overwrite if ssid was blank. I thought I just fixed this but maybe it was bad or not pushed. Thanks
@tablatronix commented on GitHub (Feb 15, 2024):
I used placeholder because I do not want wifi args resubmitting if only changing params. This way they do not get sent in plain text everytime you save, if not needed. Also we cannot populate password.
hmm I thought this fixed this
0e2016879b9df7acdeebAlso why are you restarting in the callback function anyway?
saveConfigCallback() and not using return or status? Just Curious
I wonder if wifi_ssid is not populated becuase esp32 wifi was not init or connected yet
@rusty-labs commented on GitHub (Feb 15, 2024):
Sending SSID in a plain text is totally fine.
I believe the root cause of these problems is that WiFi_SSID and _ssid are not synced, should be setter/getter instead
@rusty-labs commented on GitHub (Feb 16, 2024):
Password has the same problem
@rusty-labs commented on GitHub (Feb 16, 2024):
Ok I fixed all the issues above in my fork
github.com/rusty-labs/WiFiManager@981a540793/WiFiManager.cpp (L2110C3-L2116C4)github.com/rusty-labs/WiFiManager@981a540793/wm_strings_en.h (L66)github.com/rusty-labs/WiFiManager@981a540793/WiFiManager.cpp (L1293C3-L1303C4)I did some other fixes but I think these 3 should be sufficient to solve the problem
@tablatronix commented on GitHub (Feb 16, 2024):
What browser? Ssid and pass empty should do nothing
@rusty-labs commented on GitHub (Feb 17, 2024):
It has nothing to do with a browser
@tablatronix commented on GitHub (Feb 17, 2024):
I still dont understand this issue, or see it..
Where is your example failing?
Empty ssid should not be saved, unless you change pw but it should use WIFI_SSID, what is the test case that this returns "" ? What wifi mode are you in when saving by chance?
@rusty-labs commented on GitHub (Feb 17, 2024):
Ok I got your latest changes
Your fix doesn't work if I provide incorrect SSID and correct Password first, and then after restart provide correct SSID
But for the steps I described above it works
Btw this code shouldn't be called if _connectonsave = false
github.com/tzapu/WiFiManager@d8f8d5478a/WiFiManager.cpp (L1038C3-L1043C4)Also I don't understand why
if(_aggresiveReconn && _connectRetries<4) _connectRetries=4;If I set _connectRetries = 2, why all of a sudden it becomes 4 ? Why do you even need _aggresiveReconn ?
Overall the logic is becoming too tangled, the code needs a cleanup, too many states contradicting each other
@tablatronix commented on GitHub (Feb 17, 2024):
It says it in the source
It will probably be removed from prod, or optional, but it resolved almost 100% of connection failures reported n issues
#1067
@tablatronix commented on GitHub (Feb 17, 2024):
I will remove it and see if the bug is fixed, and see if I can move this into a workaround check for specific versions and or failure codes. Without it this was causing a absolute failure of esp connection sucess on restarts
@rusty-labs commented on GitHub (Feb 19, 2024):
_aggresiveReconn is always true and there is no public setter for this, instead you can just
_connectRetries = max(connectRetries, 4);at least the logic would be explicitly expressed instead of some hidden bool stateBut I'd get rid of it too, those who have troubles with a connection can increase number of retries in a client code
The library code shouldn't fix specific problems, it should provide an interface to do so
Also delay(1000); should be after wifiConnectNew, otherwise execution is just delayed for nothing
@tablatronix commented on GitHub (Feb 19, 2024):
The delay is necessary for this failure mode
@rusty-labs commented on GitHub (Feb 19, 2024):
Delay yes, but _aggresiveReconn no, if it's always true
@rusty-labs commented on GitHub (Feb 19, 2024):
Btw delay not needed, you already have _connectTimeout which is not used, set _connectTimeout = 1000 and it will work as a delay
@tablatronix commented on GitHub (Feb 20, 2024):
They function differently. Timeout is not the same as delay for reconnect.
I added both those options after that test was implemented as a result of its feedback.
i just need to decide how to reimplement it better so its not always required.
E (5966) wifi:Association refused temporarily, comeback time 1048 mSec@real-bombinho commented on GitHub (Mar 9, 2024):
I have version 2.0.17 and it seems this is not fixed in this version by the looks of?
I am just porting some working stuff from ESP8266 to the ESP32 and it keeps forgetting the WiFi credentials on each restart on the ESP32.
@tablatronix commented on GitHub (Mar 10, 2024):
@real-bombinho please create a new issue with some information, unrelated to this issue
@tablatronix commented on GitHub (Mar 10, 2024):
Is this really a issue? who does this?
@tablatronix commented on GitHub (Mar 10, 2024):
Closing unless you can provide how to reproduce and provide logs. I tested this as much as I can and have no issue