Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,28 @@ bool ESP8266WiFiSTAClass::reconnect() {
* @param wifioff
* @return one value of wl_status_t enum
*/
bool ESP8266WiFiSTAClass::disconnect(bool wifioff) {
bool ESP8266WiFiSTAClass::disconnect(bool wifioff, bool eraseap) {
{
return disconnect(wifioff, false);
}

/**
* Disconnect from the network
* @param wifioff
* @param eraseap
* @return one value of wl_status_t enum
*/
bool ESP8266WiFiSTAClass::disconnect(bool wifioff, bool eraseap) {
bool ret = false;

// Read current config.
struct station_config conf;
*conf.ssid = 0;
*conf.password = 0;
wifi_station_get_config(&conf);

if (eraseap) {
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.
if (WiFi.getMode() & WIFI_STA)
Expand Down
2 changes: 2 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 reconnect();

bool disconnect(bool wifioff = false);
bool disconnect(bool wifioff = false, bool eraseap = false);

bool isConnected();

Expand Down