Skip to content
Closed

eraseAP #8136

Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,22 @@ bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap)
return false;
}

/**
* @brief Reset WiFi settings in NVS to default values.
* @return true if erase succeeded
* @note: Resets SSID, password, protocol, mode, etc.
* These settings are maintained by WiFi driver in IDF.
* WiFi driver must be initialized.
*/
bool WiFiSTAClass::eraseAP(void) {
if(WiFi.getMode()==WIFI_MODE_NULL) {
if(!WiFi.enableSTA(true))
return false;
}

return esp_wifi_restore()==ESP_OK;
}

/**
* Change IP configuration settings disabling the dhcp client
* @param local_ip Static ip configuration
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class WiFiSTAClass

bool reconnect();
bool disconnect(bool wifioff = false, bool eraseap = false);
bool eraseAP(void);

bool isConnected();

Expand Down