mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1132] After Timeout, Retry Connecting to Last Known SSID/Password #969
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#969
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 @bwjohns4 on GitHub (Oct 5, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1132
This is just a question, is there a built-in way to retry connecting to the last known SSID/Password without a hard reset? I've done this and it works with the reset
if (!wifiManager.autoConnect("MY SSID")){
BWJ_DEBUG_PRINTLN("failed to connect and hit timeout, now resetting");
delay(3000);
ESP.restart();
}
but if I try:
while (!wifiManager.autoConnect("MY SSID")){
BWJ_DEBUG_PRINTLN("failed to connect and hit timeout, now retrying");
delay(3000);
}
It does not work. Is there an easy way to fix this so that a retry with the last successful credentials is possible without actually resetting and toggling relay pin states?
@tablatronix commented on GitHub (Oct 5, 2020):
Esp8266 automatically autoreconnects, you can try WiFi.begin()
@vginside commented on GitHub (May 23, 2021):
Hi @tablatronix !
I have similar problem i tried using simplified code as below:
#include <ESP8266WiFi.h> //For WiFi Connection
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
WiFiManager wifiManager;
wifiManager.setConfigPortalTimeout(10); //Use this function to timeout AP portal page; Parameter time in seconds
if(!(wifiManager.autoConnect())) // check if wifi is connected within configportaltimeout if not restart
{
Serial.println("Failed to connect");
WiFi.mode(WIFI_OFF);
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
WiFi.begin();
//ESP.restart();
}
else
{
//if you get here you have connected to the WiFi
Serial.println((String)"Connected to Wifi SSID: "+WiFi.SSID());
Serial.println((String)"Wifi password: "+WiFi.psk());
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
}
}
void loop()
{
if (WiFi.status() != WL_CONNECTED) // Keep checking if wifi Connection is connected or lost
{
Serial.print(".");
delay(500);
}
else
{
Serial.println("Connected!");
delay(500);
}
}
If configuration timesout then device wont reconnect to saved credentials this is problem for powerfail ofc. Any helps?
@vginside commented on GitHub (May 24, 2021):
Never mind I was using an older version of 0.14.0... Updating it to 0.16.0 resolved it! Not even need to write WiFi.begin() cheers! :)