Skip to content

Commit

Permalink
added new feature: isConfigured() check (we need sample file)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpsaturn committed Jul 13, 2022
1 parent db6957a commit 401ae65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ESP32WifiCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,18 @@ void ESP32WifiCLI::wifiAPConnect(bool save) {
}
}

bool ESP32WifiCLI::isConfigured() {
return wcli.loadAP(1);
}

bool ESP32WifiCLI::loadAP(int net) {
cfg.begin("wifi_cli_prefs", RO_MODE);
String key = getNetKeyName(net);
if (!cfg.isKey(String(key + "_ssid").c_str())) {
cfg.end();
return false;
}
Serial.printf("\nDefault AP: %i: [%s]\r\n", net, cfg.getString(String(key + "_ssid").c_str(), "").c_str());
// Serial.printf("\nDefault AP: %i: [%s]\r\n", net, cfg.getString(String(key + "_ssid").c_str(), "").c_str());
temp_ssid = cfg.getString(String(key + "_ssid").c_str(), "");
temp_pasw = cfg.getString(String(key + "_pasw").c_str(), "");
cfg.end();
Expand Down Expand Up @@ -359,7 +363,7 @@ void ESP32WifiCLI::begin(long baudrate) {
WiFi.mode(WIFI_STA);
Serial.flush();
delay(10);
Serial.println("\n");
Serial.println("");
loadSavedNetworks(true);
loadAP(getDefaultAP());
reconnect();
Expand Down
1 change: 1 addition & 0 deletions src/ESP32WifiCLI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ESP32WifiCLI {
void deleteNetwork(String ssid);
void loadSavedNetworks(bool addAP = true);
bool isSSIDSaved(String ssid);
bool isConfigured();
void saveNetwork(String ssid, String pasw);
String getMode();
int getDefaultAP();
Expand Down

0 comments on commit 401ae65

Please sign in to comment.