mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1243] Question: how to avoid connecting to Wifi after saving on config portal? #1064
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#1064
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 @debackel on GitHub (Apr 21, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1243
Hello,
This library is great, many thanks to the development community !!!
I am using the config portal to set up the SSID/password.
But the library automatically tries to connect after saving the wifi parameters.
How can I avoid it (I would like to manage the connection in a specific way in my state machine)?
Many thanks for the help.
Laurent
@tablatronix commented on GitHub (Apr 21, 2021):
hmm we use the native esp.begin to save and connect, nothing is implemented to save directly to flash. It would require a bit of programming, you could use the params/setup page and use custom prompts instead then handle them yourself.
@debackel commented on GitHub (Apr 22, 2021):
Many thanks for your response.
If I understand correctly, you are using the esp.begin to do both saving the settings in flash memory and to connect to the AP. Is it correct?
So, if we don't connect, the settings modified by the config portal are not saved to flash memory.
In ESP8266WiFiSTA.cpp , one of the "begin" methods has an optional parameter ("connect") to make the connection optional. couldn't we leverage this? The same exists for esp32 (in WiFiSTA.cpp).
That will make the addition in WiFiManager pretty easy, isn't it?
If so, may I propose my change (commit)?
@tablatronix commented on GitHub (Apr 22, 2021):
ahhh, yeah I forgot about that
@tablatronix commented on GitHub (Apr 22, 2021):
ok give that a try, I have not tested it, and I am not sure how to handle the save returns, it still returns status, so you will have to also handle that or use breakafterconfig etc.
@tablatronix commented on GitHub (Apr 22, 2021):
This should only affect saving new/changing creds, saving the same is ignored always anyway..
@debackel commented on GitHub (Apr 22, 2021):
Thank you so much !!!!
I'll give it a try as soon as possible.
On your concern about ignoring the same credentials, why is this an issue? why would you want to save the same thing as what is stored in flash already? I probably didn't get the point.
Questions: the way the patch is done, won't you have a "WL_CONNECTED" returned (even without being connected)? Isn't this an issue? Also, the debug output will display "Connect to new AP ...", isn't it?
Shouldn't we output differentiated debug output and return code?
@tablatronix commented on GitHub (Apr 22, 2021):
I use the same wificonnect code for all , I would have to refactor this more and do not plan on doing that atm, as I am about cut a beta
Debugging is easy to clean up,
The return will be WL_CONNECTED yes, not sure how else to handle that, I could invert it
@tablatronix commented on GitHub (Apr 22, 2021):
ok going to try returning idle and added alt debug
@debackel commented on GitHub (Apr 23, 2021):
I did a test this morning (not deep testing, but quick validation), this works great on my D1 Mini.
Thank you so much !
This way, I can manage myself the connection cycle.
@debackel commented on GitHub (Apr 24, 2021):
I made deeper testing today. The patch is functional. However, the debug output at different levels is not adequate anymore, as the methods were originally designed for connecting (not for only saving credentials). Also, in processConfigPortal, we expect connectWifi to return WL_CONNECTED from the wifi.begin, while now, "idle" can be returned as well.
As a consequence, processConfigPortal goes to the error branch, and the config portal is not shutdown properly. I will debug further and hopefully propose a patch to have all this treated properly.
@tablatronix commented on GitHub (Apr 24, 2021):
Are you using non blocking or blocking?
Did you try using shouldbreakafterconfig ?
@debackel commented on GitHub (Apr 24, 2021):
I am using non blocking mode. No, I don't use shouldbreakafterconfig. Can you tell me what this actually does?
@tablatronix commented on GitHub (Apr 24, 2021):
It looks like wifi begin returns false also
@debackel commented on GitHub (Apr 24, 2021):
I am not sure this is wifi.begin. wifi.begin returns an integer value. But in wifimanager, the return code of wifi.begin is tested like this: if(!ret) DEBUG_WM(DEBUG_ERROR,F("[ERROR] wifi begin failed"));
As ret = 1 in case of connection, this is OK. But if you don't connect, it returns another value (idle, I guess), which doesn't pass the boolean type of testing.
@tablatronix commented on GitHub (Apr 24, 2021):
Yeah I just noticed connectWifi returns conres, I missed that, it was kludged a little as I will rewrite it all next version
@tablatronix commented on GitHub (Apr 24, 2021):
I tried fixing it but now I am crashing my esp... ugh
@debackel commented on GitHub (Apr 24, 2021):
Do you want me to write a patch? You would review it, of course.
@tablatronix commented on GitHub (Apr 24, 2021):
Somehow this is exposing some bug somewhere else.. or in esp lib
NO clue, I will have to decode this first
@tablatronix commented on GitHub (Apr 24, 2021):
all I changed was
@tablatronix commented on GitHub (Apr 24, 2021):
Ok I added some fixes, if this doesn't work, I will have to reimplement the state machine as this has been kludged too much
@debackel commented on GitHub (Apr 25, 2021):
Many thanks.
Re tested today, seems OK, I think we can close it. This is great stuff, thank you once again !!!