WiFiManager: cannot create an AP after autoConnect failed
Basic Infos
Hardware
WiFimanager Branch/Release: Release
Esp8266/Esp32:
Hardware: ESP8266
Core Version: Release v2.0.3-apha Development
Description
I want to create an offline mode access point to provide some web pages after the autoConnect timeout, but after the autoConnect timeout, I can’t search the offline mode access point, whether it’s AP or AP_ STA mode, below it’s a minimum version program, please help me , thanks
Settings in IDE
Module: NodeMcu
Additional libraries:
Sketch
#BEGIN
#include <WiFiManager.h>
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFiManager wm;
wm.setDebugOutput(true);
wm.setTimeout(30);
bool res;
Serial.println("auto_test.");
res = wm.autoConnect("auto_test");
if(!res) {
Serial.println("offline mode");
WiFi.mode(WIFI_AP_STA);
IPAddress apIP(192, 168, 4, 1);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Offline");
}
else {
Serial.println("connected.");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
#END
Debug Messages
14:18:48.453 -> *WM: [2] setSTAConfig static ip not set, skipping
14:18:48.453 -> *WM: [1] Connecting to SAVED AP: yuan_mi11
14:18:48.453 -> *WM: [3] Using Password: 123456
14:18:48.453 -> *WM: [3] WiFi station enable
14:18:48.453 -> *WM: [3] enableSTA PERSISTENT ON
14:18:48.453 -> *WM: [1] connectTimeout not set, ESP waitForConnectResult...
14:18:57.199 -> *WM: [2] Connection result: WL_NO_SSID_AVAIL
14:18:57.199 -> *WM: [3] lastconxresult: WL_NO_SSID_AVAIL
14:18:57.199 -> *WM: [1] AutoConnect: FAILED
14:18:57.199 -> *WM: [2] Starting Config Portal
14:18:57.199 -> *WM: [3] WIFI station disconnect
14:18:57.199 -> *WM: [3] WiFi station enable
14:18:57.199 -> *WM: [2] Disabling STA
14:18:57.199 -> *WM: [2] Enabling AP
14:18:57.199 -> *WM: [1] StartAP with SSID: auto_test
14:18:57.677 -> *WM: [2] AP has anonymous access!
14:18:57.677 -> *WM: [1] SoftAP Configuration
14:18:57.724 -> *WM: [1] --------------------
14:18:57.724 -> *WM: [1] ssid: auto_test
14:18:57.724 -> *WM: [1] password:
14:18:57.724 -> *WM: [1] ssid_len: 9
14:18:57.724 -> *WM: [1] channel: 1
14:18:57.724 -> *WM: [1] authmode:
14:18:57.724 -> *WM: [1] ssid_hidden:
14:18:57.724 -> *WM: [1] max_connection: 4
14:18:57.724 -> *WM: [1] country: CN
14:18:57.724 -> *WM: [1] beacon_interval: 100(ms)
14:18:57.724 -> *WM: [1] --------------------
14:18:58.200 -> *WM: [1] AP IP address: 192.168.4.1
14:18:58.247 -> *WM: [3] setupConfigPortal
14:18:58.247 -> *WM: [1] Starting Web Portal
14:18:58.247 -> *WM: [3] dns server started with ip: 192.168.4.1
14:18:58.247 -> *WM: [2] HTTP server started
14:19:00.392 -> *WM: [2] WiFi Scan completed in 2185 ms
14:19:00.392 -> *WM: [2] Config Portal Running, blocking, waiting for clients...
14:19:13.818 -> *WM: [3] -> connectivitycheck.platform.hicloud.com
14:19:13.818 -> *WM: [2] <- Request redirected to captive portal
14:19:18.317 -> *WM: [2] Portal Timeout In 8 seconds
14:19:27.171 -> *WM: [1] config portal has timed out
14:19:27.171 -> *WM: [3] configportal abort
14:19:27.171 -> *WM: [2] disconnect configportal
14:19:28.175 -> *WM: [2] restoring usermode STA
14:19:28.175 -> *WM: [2] WiFi Reconnect, was idle
14:19:28.216 -> *WM: [2] wifi status: WL_DISCONNECTED
14:19:28.216 -> *WM: [2] wifi mode: STA
14:19:28.216 -> *WM: [1] config portal exiting
14:19:28.216 -> offline mode
14:19:28.263 -> *WM: [3] unloading
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 24
try to add a delay after changing the mode? worked for me once but not always, very strange
Ok I think I have it now, let me play with it a bit
Sorry I keep forgetting this, So does esp give you a AP create failed error?
Yes, I also have the same problem. WiFi manager prevents creating an AP after configuring SSID Password with the portal. Need to restart the esp to resolve this. Any updates?
Hi I have deleted these two lines , but it still not work.
res = wm.autoConnect("auto_test");
if(!res) {
Serial.println("offline mode");
WiFi.mode(WIFI_AP_STA);
// IPAddress apIP(192, 168, 10, 1);
// WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Offline");
}
and it works after I didn’t use wm.autoConnect:
res = false; //wm.autoConnect("auto_test");
if(!res) {
Serial.println("offline mode");
WiFi.mode(WIFI_AP_STA);
IPAddress apIP(192, 168, 10, 1);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Offline");
}
So I believe that it is some code of wifiManger that affects create AP after autoConnect timeout, and I also check wifiManager source code and try ,but still not solved . Please help me, thanks a lot.