WiFiManager: getWiFiIsSaved() returns true if no WiFi is saved when no reset is called
Basic Infos
Hardware
WiFimanager Branch/Release:
- Master
- Development
Esp8266/Esp32:
- ESP8266
- ESP32
Hardware: ESP-12e, esp01, esp25
- ESP01
- ESP12 E/F/S (nodemcu, wemos, feather)
- Other: TTGO T8
ESP Core Version: 2.4.0, staging
- 2.3.0
- 2.4.0
- staging (master/dev)
Description
As the title says, when I call getWiFiIsSaved()
it returns true if I don’t call resetSettings()
before it after startup/deep sleep.
If I reset the settings on the initial startup, the method works as expected, returning false
if the AP is exited without configuring WiFi settings. On subsequent startups, however, it returns true
if the settings are not reset explicitly.
I would expect it to still return false
since no settings have been saved.
Note: Even without the deep sleep, as long as I don’t call resetSettings()
, getWiFiIsSaved()
returns true
.
Sketch
#include <WiFiManager.h>
#define uS_TO_S_FACTOR 1000000ULL
WiFiManager wm;
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
if(esp_sleep_get_wakeup_cause() == 0) {
wm.resetSettings();
}
Serial.println("WiFi saved? " + String(wm.getWiFiIsSaved() ? "YES" : "NO"));
if(wm.autoConnect("AutoConnectAP","password")) {
Serial.println("Failed to connect");
// ESP.restart();
} else {
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
Serial.println("WiFi saved? " + String(wm.getWiFiIsSaved() ? "YES" : "NO"));
uint8_t sleepSeconds = 5;
esp_sleep_enable_timer_wakeup(sleepSeconds * uS_TO_S_FACTOR);
Serial.println("Sleeping for " + String(sleepSeconds) + " seconds...");
esp_deep_sleep_start();
}
void loop() {
// put your main code here, to run repeatedly:
}
Debug Messages
*WM: [1] resetSettings
*WM: [3] WiFi_enableSTA enable
*WM: [1] SETTINGS ERASED
WiFi saved? NO
*WM: [1] AutoConnect
*WM: [1] No Credentials are Saved, skipping connect
*WM: [2] Starting Config Portal
*WM: [2] AccessPoint set password is VALID
*WM: [1] password
*WM: [3] WiFi station disconnect
*WM: [3] WiFi_enableSTA enable
*WM: [2] Disabling STA
*WM: [2] Enabling AP
*WM: [1] StartAP with SSID: AutoConnectAP
*WM: [1] SoftAP Configuration
*WM: [1] --------------------
*WM: [1] ssid: AutoConnectAP
*WM: [1] password: password
*WM: [1] ssid_len: 13
*WM: [1] channel: 1
*WM: [1] authmode: 3
*WM: [1] ssid_hidden:
*WM: [1] max_connection: 4
*WM: [1] country: CN
*WM: [1] beacon_interval: 100(ms)
*WM: [1] --------------------
*WM: [1] AP IP address: 192.168.4.1
*WM: [3] setupConfigPortal
*WM: [1] Starting Web Portal
*WM: [3] dns server started with ip: 192.168.4.1
*WM: [2] HTTP server started
*WM: [2] WiFi Scan completed in 3105 ms
*WM: [2] Config Portal Running, blocking, waiting for clients...
*WM: [3] -> connectivitycheck.platform.hicloud.com
*WM: [2] <- Request redirected to captive portal
*WM: [3] -> connectivitycheck.platform.hicloud.com
*WM: [2] <- Request redirected to captive portal
*WM: [3] -> connectivitycheck.platform.hicloud.com
*WM: [2] <- Request redirected to captive portal
*WM: [3] -> connectivitycheck.platform.hicloud.com
*WM: [2] <- Request redirected to captive portal
*WM: [3] -> connectivitycheck.platform.hicloud.com
*WM: [2] <- Request redirected to captive portal
*WM: [2] <- HTTP Root
*WM: [3] -> 192.168.4.1
*WM: [3] lastconxresulttmp: WL_IDLE_STATUS
*WM: [3] lastconxresult: WL_DISCONNECTED
*WM: [2] Scan is cached 7300 ms ago
*WM: [3] -> 192.168.4.1
*WM: [2] <- HTTP Exit
*WM: [3] configportal abort
*WM: [2] disconnect configportal
*WM: [2] restoring usermode STA
*WM: [2] wifi status: WL_DISCONNECTED
*WM: [2] wifi mode: STA
*WM: [1] config portal exiting
connected...yeey :)
WiFi saved? NO
Sleeping for 5 seconds...
ets Jun 8 2016 00:22:57
rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
WiFi saved? YES
*WM: [1] AutoConnect
*WM: [2] ESP32 event handler enabled
*WM: [2] Connecting as wifi client...
*WM: [3] STA static IP:
*WM: [2] setSTAConfig static ip not set, skipping
*WM: [1] No wifi save required, skipping
*WM: [2] Connection result: WL_NO_SSID_AVAIL
*WM: [3] lastconxresult: WL_NO_SSID_AVAIL
*WM: [1] AutoConnect: FAILED
*WM: [2] Starting Config Portal
*WM: [2] AccessPoint set password is VALID
*WM: [1] password
*WM: [3] WiFi station disconnect
*WM: [3] WiFi_enableSTA enable
*WM: [2] Disabling STA
*WM: [2] Enabling AP
*WM: [1] StartAP with SSID: AutoConnectAP
*WM: [1] SoftAP Configuration
*WM: [1] --------------------
*WM: [1] ssid: AutoConnectAP
*WM: [1] password: password
*WM: [1] ssid_len: 13
*WM: [1] channel: 1
*WM: [1] authmode: 3
*WM: [1] ssid_hidden:
*WM: [1] max_connection: 4
*WM: [1] country: CN
*WM: [1] beacon_interval: 100(ms)
*WM: [1] --------------------
*WM: [1] AP IP address: 192.168.4.1
*WM: [3] setupConfigPortal
*WM: [1] Starting Web Portal
*WM: [3] dns server started with ip: 192.168.4.1
*WM: [2] HTTP server started
*WM: [2] WiFi Scan ASYNC completed in 3305 ms
*WM: [2] WiFi Scan ASYNC found: 38
*WM: [2] WiFi Scan completed in 3306 ms
*WM: [2] Config Portal Running, blocking, waiting for clients...
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19
Sorry about that, its actually not in that example, Ill add it!
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.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,