mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #922] Save SSID and PSW #780
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#780
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 @ASLABSIT on GitHub (Aug 11, 2019).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/922
Basic Infos
Hardware
WiFimanager Branch/Release:
Esp8266/Esp32:
Hardware: ESP-12e, esp01, esp25
ESP Core Version: 2.4.0, staging
Description
Problem description
In case of WIFI router down and leater restarted WiFi.SSID() will be empty and WM goes in AP mode.
*WM: [1] AutoConnect
*WM: [2] Connecting as wifi client...
*WM: [1] STA static IP:
*WM: [2] setSTAConfig static ip not set
*WM: [3] WIFI station disconnect
*WM: [1] No saved credentials, skipping wifi ??????
*WM: [2] Connection result: WL_NO_SSID_AVAIL
*WM: [3] lastconxresult: WL_NO_SSID_AVAIL
*WM: [1] AutoConnect: FAILED
*WM: [3] WIFI station disconnect
*WM: [3] WiFi station enable
*WM: [2] Disabling STA
*WM: [2] Enabling AP
*WM: [1] StartAP with SSID: ASlabs
*WM: [2] AP has anonymous access!
*WM: [1] AP IP address: 192.168.4.1
Probably is ESP8266 WiFi issue
I simply SOLVED saving _MYssid and _MYpass end try a new connection.
Function uint8_t WiFiManager::connectWifi(String ssid, String pass)
become:
// @todo refactor this up into seperate functions
// one for connecting to flash , one for new client
// clean up, flow is convoluted, and causes bugs
uint8_t WiFiManager::connectWifi(String ssid, String pass) {
DEBUG_WM(DEBUG_VERBOSE,F("Connecting as wifi client..."));
uint8_t connRes = (uint8_t)WL_NO_SSID_AVAIL;
setSTAConfig();
//@todo catch failures in set_config
// make sure sta is on before
beginso it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !)if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status
// if ssid argument provided connect to that
if (ssid != "") {
wifiConnectNew(ssid,pass);
if(_saveTimeout > 0){
connRes = waitForConnectResult(_saveTimeout); // use default save timeout for saves to prevent bugs in esp->waitforconnectresult loop
}
else {
connRes = waitForConnectResult(0);
}
}
else {
// connect using saved ssid if there is one
if (WiFi_hasAutoConnect()) {
wifiConnectDefault();
connRes = waitForConnectResult();
}
else {
DEBUG_WM(F("No saved credentials, skipping wifi"));
DEBUG_WM(connRes);
}
}
//***** ASLABSIT ******//
// Try with my saved credential
if (connRes == WL_NO_SSID_AVAIL)
{
DEBUG_WM(F("Using MY CONFIG parameter"));
}
//***** ASLABSIT ******//
....
_MYssid, _MYpass were previosly saved.
Probably there will be a better way to do that ;-) ....this is my workaround.
Regards.
@tablatronix commented on GitHub (Aug 11, 2019):
If your credentials are not being saved you have a memory problem, erase your flash
this is completely unnecessary as it is already the supposed to be the default behavior.