Skip to content

eraseAP #8136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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