mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #280] Calling WiFi.disconnect() seems to wipe WiFiManagers SSID/Password settings? #237
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#237
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 @horendus on GitHub (Jan 7, 2017).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/280
Hey
I have been using WiFiManager for a project, fantastic library!
I have however run into a problem, my project needs to be able to connect/disconnect wifi at will.
Connecting is fine using wifiManager.autoConnect(); however if I call WiFi.disconnect(); at any point I cannot re connect to my wifi using wifiManager.autoConnect(); unless I go through the portal again and re enter my wifi detail.
The only think I can think of is WiFi.disconnect(); is wiping the saved wifi credentials for the library.
Is there another way I should be disconnecting from wifi? WiFiManager doesnt have a disconnect function.
Thanks for any help you can provide!
@ortegafernando commented on GitHub (Jan 12, 2017):
See this: https://github.com/tzapu/WiFiManager/issues/242
It is about persistent(false)
@tablatronix commented on GitHub (Jan 12, 2017):
persistent on or off ?
@ortegafernando commented on GitHub (Jan 13, 2017):
From this, for me is clear (almost ;) : https://github.com/esp8266/Arduino/blob/master/doc/esp8266wifi/generic-class.md
that explain this:
"""""
Module is able to reconnect to last used Wi-Fi network on power up or reset basing on settings stored in specific sectors of flash memory. By default these settings are written to flash each time they are used in functions like WiFi.begin(ssid, password). This happens no matter if SSID or password has been actually changed.
This might result in some wear of flash memory depending on how often such functions are called.
Setting persistent to false will get SSID / password written to flash only if currently used values do not match what is already stored in flash.
Please note that functions WiFi.disconnect or WiFi.softAPdisconnect reset currently used SSID / password. If persistent is set to false, then using these functions will not affect SSID / password stored in flash.
To learn more about this functionality, and why it has been introduced, check issue report #1054
""""
So with persistent(true) Wifi.disconnect ERASES the SSID and password (usefull if you want to sell a module and don't want anyone to get your SSID and password from flash memory).
With persistent(false) Wifi.disconnect doesn't erase anything.
Meanwhile I have forked @kentaylor library and added option to use persistent(false), I will try to use it and see if there is any problema (I have still not use it)
I think will be the best to have persistent = false as default value in this library.
Regards
@tablatronix commented on GitHub (Jan 13, 2017):
I suppose the question is why is your sketch calling disconnect to begin with?
I think you can simply change modes, but you might be doing something like turning radio on and off, not sure.
I also thought he made his branch to specifically use persistence to store the creds in eeprom, original wifi manager was manually doing this.
I do not really understand how you are supposed to save the credentials to eeprom if not using persistent, that is the whole point of it. Nor do I understand what issue you are trying to solve.
You can disconnect from wifi by changing the wifi mode or you can write your own disconnect function
and call
wifi_station_disconnect()directly thenWiFi.enableSTA(false)or simply wrap your disconnects
but i am not sure if this wipes your current config, so calling begin again might not work, might need to test that
@azevedo-manuel commented on GitHub (Jan 4, 2018):
Yes, I confirm this and the workaround by @tablatronix works with a minor change:
Also answerting @tablatronix, I call this function when a user presses a button to call Wi-Fi Manager. If the ESP8266 is still connected to a network, without
WiFi.disconnect()it would still be connected to that network and it would serve the Wi-Fi Manager webpage if a user connected to it.