mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1119] getWiFiIsSaved() returns true if no WiFi is saved when no reset is called #955
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#955
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 @Lithimlin on GitHub (Sep 1, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1119
Basic Infos
Hardware
WiFimanager Branch/Release:
Esp8266/Esp32:
Hardware: ESP-12e, esp01, esp25
ESP Core Version: 2.4.0, staging
Description
As the title says, when I call
getWiFiIsSaved()it returns true if I don't callresetSettings()before it after startup/deep sleep.If I reset the settings on the initial startup, the method works as expected, returning
falseif the AP is exited without configuring WiFi settings. On subsequent startups, however, it returnstrueif the settings are not reset explicitly.I would expect it to still return
falsesince no settings have been saved.Note: Even without the deep sleep, as long as I don't call
resetSettings(),getWiFiIsSaved()returnstrue.Sketch
Debug Messages
@Lithimlin commented on GitHub (Sep 1, 2020):
I've traveled down the rabbit hole a bit and found out that
getWiFiSSID()returns a specific string when not reset after startup/deep sleep.Here is the relevant line of code:
When resetting the settings, the output is
So there is no SSID saved since it was reset.
Without the reset, the output always is
@tablatronix commented on GitHub (Sep 1, 2020):
This function returns if the esp has credentials stored in flash. Other than that I have no idea what you are doing but it has nothing to do with saving in wifimanager.
Also this function behaves differently on esp32, esp32 does not expose the wifi creds if wifi has not been init yet. It is how the esp32 works,
@Lithimlin commented on GitHub (Sep 1, 2020):
Alternatively, is there a method that connects to a WiFi network when one has been configured and returns an indicator when that fails? What I want to do is connect to a previously configured WiFi network if it is available but not start the AP when that fails.
@tablatronix commented on GitHub (Sep 1, 2020):
They way to use this would be to always start the CP if wifiissaved == false; meaning there are no credentials saved in this esp and it is new or erased
@tablatronix commented on GitHub (Sep 1, 2020):
if wifiissaved()
wifi.begin()
Or you can use autoconnect and use the disablecp settting
See the dev/ examples for almost all options
@Lithimlin commented on GitHub (Sep 1, 2020):
So have an extra
RTC_DATA_ATTR bool wifiConfiguredvariable to externally keep track of whether it has been configured before?@Lithimlin commented on GitHub (Sep 1, 2020):
I'm confused what you mean.
I assume you mean config portal when you say CP. So does that mean that if I disable the CP, the ESP will also not start a soft AP and just try to connect to the stored WiFi network?
@tablatronix commented on GitHub (Sep 1, 2020):
Yes well config portal
@tablatronix commented on GitHub (Sep 1, 2020):
https://github.com/tzapu/WiFiManager/blob/development/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino#L251
@tablatronix commented on GitHub (Sep 1, 2020):
oops that not it
@Lithimlin commented on GitHub (Sep 1, 2020):
Using
wm.setCaptivePortalEnable(false);does not actually disable the soft AP though (I just tried it and that does make sense). So what is the correct way to do it?As it is now, the code above (
wm.autoConnect("AutoConnectAP","password")) always starts a soft AP if there is no WiFi config saved, even when disabling the captive portal. I have not found a method to disable the config portal itself. The only thing I found wasstopConfigPortal()but sinceautoConnect(...)is blocking, calling that won't help.@tablatronix commented on GitHub (Sep 1, 2020):
Sorry about that, its actually not in that example, Ill add it!
@Lithimlin commented on GitHub (Sep 1, 2020):
Ah! Thanks a lot! That's probably what I was looking for.
Quick question: Does it also prevent the explicit starting of a config portal via
wm.startConfigPortal?@tablatronix commented on GitHub (Sep 1, 2020):
no, good point, maybe auto* would be a better name
@Lithimlin commented on GitHub (Sep 1, 2020):
Yes! This method was what I was looking for. Although, is it intended that
autoConnectreturns true when it didn't connect to anything and the config portal is disabled?@tablatronix commented on GitHub (Sep 1, 2020):
hmm, i would not think so, that sounds wrong.
is that what you are seeing ?
@Lithimlin commented on GitHub (Sep 1, 2020):
Yes, here's the updated code:
I immediately exit the config portal the first time, without configuring the WiFi and get the following output:
So it actually also returns true the first time around when I simply exit the CP.
@Lithimlin commented on GitHub (Sep 1, 2020):
Well, nevermind that, I was missing a
!in front of thewm.autoConnect(...), so it's actually always returning false as it should@Lithimlin commented on GitHub (Sep 1, 2020):
So thanks for the help!