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

Commit 302ba0d

Browse files
authored
Merge pull request #28 from hmueller01/public_dynamic_data
added public methods to load and save dynamic data
2 parents f79e60c + 3908fa2 commit 302ba0d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/ESP_WiFiManager_Lite.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,47 @@ class ESP_WiFiManager_Lite
12711271

12721272
//////////////////////////////////////
12731273

1274+
#if USE_DYNAMIC_PARAMETERS
1275+
1276+
bool extLoadDynamicData()
1277+
{
1278+
#if ESP8266
1279+
// SPIFFS and LittleFS do auto-format if not yet
1280+
if (!FileFS.begin())
1281+
#else
1282+
// Format SPIFFS if not yet
1283+
if (!FileFS.begin(true))
1284+
#endif
1285+
{
1286+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1287+
return false;
1288+
}
1289+
1290+
return loadDynamicData();
1291+
}
1292+
1293+
//////////////////////////////////////////////
1294+
1295+
void extSaveDynamicData()
1296+
{
1297+
#if ESP8266
1298+
// SPIFFS and LittleFS do auto-format if not yet
1299+
if (!FileFS.begin())
1300+
#else
1301+
// Format SPIFFS if not yet
1302+
if (!FileFS.begin(true))
1303+
#endif
1304+
{
1305+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1306+
return;
1307+
}
1308+
1309+
saveDynamicData();
1310+
}
1311+
1312+
#endif
1313+
1314+
//////////////////////////////////////
12741315

12751316
private:
12761317
String ipAddress = "0.0.0.0";
@@ -1290,6 +1331,7 @@ class ESP_WiFiManager_Lite
12901331

12911332
unsigned long configTimeout;
12921333
bool hadConfigData = false;
1334+
bool hadDynamicData = false;
12931335

12941336
bool isForcedConfigPortal = false;
12951337
bool persForcedConfigPortal = false;
@@ -1675,6 +1717,11 @@ class ESP_WiFiManager_Lite
16751717

16761718
bool loadDynamicData()
16771719
{
1720+
if (hadDynamicData)
1721+
{
1722+
return true;
1723+
}
1724+
16781725
int checkSum = 0;
16791726
int readCheckSum;
16801727
totalDataSize = sizeof(ESP_WM_LITE_config) + sizeof(readCheckSum);
@@ -1727,6 +1774,7 @@ class ESP_WiFiManager_Lite
17271774
return false;
17281775
}
17291776

1777+
hadDynamicData = true;
17301778
return true;
17311779
}
17321780

0 commit comments

Comments
 (0)