mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-21 21:22:31 +03:00
Add eraseap option to WiFi disconnect method. (#8758)
Add eraseCredentials option to WiFi disconnect method (legacy default: true)
This commit is contained in:
@ -353,15 +353,32 @@ bool ESP8266WiFiSTAClass::reconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from the network
|
* Disconnect from the network with clearing saved credentials
|
||||||
* @param wifioff
|
* @param wifioff Bool indicating whether STA should be disabled.
|
||||||
* @return one value of wl_status_t enum
|
* @return one value of wl_status_t enum
|
||||||
*/
|
*/
|
||||||
bool ESP8266WiFiSTAClass::disconnect(bool wifioff) {
|
bool ESP8266WiFiSTAClass::disconnect(bool wifioff) {
|
||||||
|
// Disconnect with clearing saved credentials.
|
||||||
|
return disconnect(wifioff, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from the network
|
||||||
|
* @param wifioff Bool indicating whether STA should be disabled.
|
||||||
|
* @param eraseCredentials Bool indicating whether saved credentials should be erased.
|
||||||
|
* @return one value of wl_status_t enum
|
||||||
|
*/
|
||||||
|
bool ESP8266WiFiSTAClass::disconnect(bool wifioff, bool eraseCredentials) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
// Read current config.
|
||||||
struct station_config conf;
|
struct station_config conf;
|
||||||
*conf.ssid = 0;
|
wifi_station_get_config(&conf);
|
||||||
*conf.password = 0;
|
|
||||||
|
if (eraseCredentials) {
|
||||||
|
memset(&conf.ssid, 0, sizeof(conf.ssid));
|
||||||
|
memset(&conf.password, 0, sizeof(conf.password));
|
||||||
|
}
|
||||||
|
|
||||||
// API Reference: wifi_station_disconnect() need to be called after system initializes and the ESP8266 Station mode is enabled.
|
// API Reference: wifi_station_disconnect() need to be called after system initializes and the ESP8266 Station mode is enabled.
|
||||||
if (WiFi.getMode() & WIFI_STA)
|
if (WiFi.getMode() & WIFI_STA)
|
||||||
|
@ -48,7 +48,9 @@ class ESP8266WiFiSTAClass: public LwipIntf {
|
|||||||
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
|
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
|
||||||
|
|
||||||
bool reconnect();
|
bool reconnect();
|
||||||
|
|
||||||
bool disconnect(bool wifioff = false);
|
bool disconnect(bool wifioff = false);
|
||||||
|
bool disconnect(bool wifioff, bool eraseCredentials);
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user