Skip to content

Commit 758b4eb

Browse files
eraseAP (espressif#8148)
1 parent 5c92a02 commit 758b4eb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,22 @@ bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap)
366366
return false;
367367
}
368368

369+
/**
370+
* @brief Reset WiFi settings in NVS to default values.
371+
* @return true if erase succeeded
372+
* @note: Resets SSID, password, protocol, mode, etc.
373+
* These settings are maintained by WiFi driver in IDF.
374+
* WiFi driver must be initialized.
375+
*/
376+
bool WiFiSTAClass::eraseAP(void) {
377+
if(WiFi.getMode()==WIFI_MODE_NULL) {
378+
if(!WiFi.enableSTA(true))
379+
return false;
380+
}
381+
382+
return esp_wifi_restore()==ESP_OK;
383+
}
384+
369385
/**
370386
* Change IP configuration settings disabling the dhcp client
371387
* @param local_ip Static ip configuration

Diff for: libraries/WiFi/src/WiFiSTA.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class WiFiSTAClass
5353

5454
bool reconnect();
5555
bool disconnect(bool wifioff = false, bool eraseap = false);
56+
bool eraseAP(void);
5657

5758
bool isConnected();
5859

0 commit comments

Comments
 (0)