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

libraries/WiFi/src/WiFiSTA.cpp

Lines changed: 16 additions & 0 deletions
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

libraries/WiFi/src/WiFiSTA.h

Lines changed: 1 addition & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy