Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from hmueller01/public_dynamic_data
Browse files Browse the repository at this point in the history
added public methods to load and save dynamic data
  • Loading branch information
khoih-prog authored Jan 13, 2023
2 parents f79e60c + 3908fa2 commit 302ba0d
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/ESP_WiFiManager_Lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,47 @@ class ESP_WiFiManager_Lite

//////////////////////////////////////

#if USE_DYNAMIC_PARAMETERS

bool extLoadDynamicData()
{
#if ESP8266
// SPIFFS and LittleFS do auto-format if not yet
if (!FileFS.begin())
#else
// Format SPIFFS if not yet
if (!FileFS.begin(true))
#endif
{
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
return false;
}

return loadDynamicData();
}

//////////////////////////////////////////////

void extSaveDynamicData()
{
#if ESP8266
// SPIFFS and LittleFS do auto-format if not yet
if (!FileFS.begin())
#else
// Format SPIFFS if not yet
if (!FileFS.begin(true))
#endif
{
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
return;
}

saveDynamicData();
}

#endif

//////////////////////////////////////

private:
String ipAddress = "0.0.0.0";
Expand All @@ -1290,6 +1331,7 @@ class ESP_WiFiManager_Lite

unsigned long configTimeout;
bool hadConfigData = false;
bool hadDynamicData = false;

bool isForcedConfigPortal = false;
bool persForcedConfigPortal = false;
Expand Down Expand Up @@ -1675,6 +1717,11 @@ class ESP_WiFiManager_Lite

bool loadDynamicData()
{
if (hadDynamicData)
{
return true;
}

int checkSum = 0;
int readCheckSum;
totalDataSize = sizeof(ESP_WM_LITE_config) + sizeof(readCheckSum);
Expand Down Expand Up @@ -1727,6 +1774,7 @@ class ESP_WiFiManager_Lite
return false;
}

hadDynamicData = true;
return true;
}

Expand Down

0 comments on commit 302ba0d

Please sign in to comment.