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

Commit 420a3cc

Browse files
committed
added public methods to load and save dynamic data
1 parent 964ba50 commit 420a3cc

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/ESPAsync_WiFiManager_Lite.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,48 @@ class ESPAsync_WiFiManager_Lite
12951295

12961296
//////////////////////////////////////
12971297

1298+
#if USE_DYNAMIC_PARAMETERS
1299+
1300+
bool extLoadDynamicData()
1301+
{
1302+
#if ESP8266
1303+
// SPIFFS and LittleFS do auto-format if not yet
1304+
if (!FileFS.begin())
1305+
#else
1306+
// Format SPIFFS if not yet
1307+
if (!FileFS.begin(true))
1308+
#endif
1309+
{
1310+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1311+
return false;
1312+
}
1313+
1314+
return loadDynamicData();
1315+
}
1316+
1317+
//////////////////////////////////////////////
1318+
1319+
void extSaveDynamicData()
1320+
{
1321+
#if ESP8266
1322+
// SPIFFS and LittleFS do auto-format if not yet
1323+
if (!FileFS.begin())
1324+
#else
1325+
// Format SPIFFS if not yet
1326+
if (!FileFS.begin(true))
1327+
#endif
1328+
{
1329+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1330+
return;
1331+
}
1332+
1333+
saveDynamicData();
1334+
}
1335+
1336+
#endif
1337+
1338+
//////////////////////////////////////
1339+
12981340

12991341
private:
13001342
String ipAddress = "0.0.0.0";
@@ -1313,6 +1355,7 @@ class ESPAsync_WiFiManager_Lite
13131355

13141356
unsigned long configTimeout;
13151357
bool hadConfigData = false;
1358+
bool hadDynamicData = false;
13161359

13171360
bool isForcedConfigPortal = false;
13181361
bool persForcedConfigPortal = false;
@@ -1696,6 +1739,11 @@ class ESPAsync_WiFiManager_Lite
16961739

16971740
bool loadDynamicData()
16981741
{
1742+
if (hadDynamicData)
1743+
{
1744+
return true;
1745+
}
1746+
16991747
int checkSum = 0;
17001748
int readCheckSum;
17011749
totalDataSize = sizeof(ESP_WM_LITE_config) + sizeof(readCheckSum);
@@ -1748,6 +1796,7 @@ class ESPAsync_WiFiManager_Lite
17481796
return false;
17491797
}
17501798

1799+
hadDynamicData = true;
17511800
return true;
17521801
}
17531802

0 commit comments

Comments
 (0)