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

Commit 584c373

Browse files
committed
added public methods to load and save dynamic data
1 parent 2244ae0 commit 584c373

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
@@ -1251,6 +1251,47 @@ class ESP_WiFiManager_Lite
12511251

12521252
//////////////////////////////////////
12531253

1254+
#if USE_DYNAMIC_PARAMETERS
1255+
1256+
bool extLoadDynamicData()
1257+
{
1258+
#if ESP8266
1259+
// SPIFFS and LittleFS do auto-format if not yet
1260+
if (!FileFS.begin())
1261+
#else
1262+
// Format SPIFFS if not yet
1263+
if (!FileFS.begin(true))
1264+
#endif
1265+
{
1266+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1267+
return false;
1268+
}
1269+
1270+
return loadDynamicData();
1271+
}
1272+
1273+
//////////////////////////////////////////////
1274+
1275+
void extSaveDynamicData()
1276+
{
1277+
#if ESP8266
1278+
// SPIFFS and LittleFS do auto-format if not yet
1279+
if (!FileFS.begin())
1280+
#else
1281+
// Format SPIFFS if not yet
1282+
if (!FileFS.begin(true))
1283+
#endif
1284+
{
1285+
ESP_WML_LOGERROR(F("SPIFFS/LittleFS failed!"));
1286+
return;
1287+
}
1288+
1289+
saveDynamicData();
1290+
}
1291+
1292+
#endif
1293+
1294+
//////////////////////////////////////
12541295

12551296
private:
12561297
String ipAddress = "0.0.0.0";
@@ -1268,6 +1309,7 @@ class ESP_WiFiManager_Lite
12681309

12691310
unsigned long configTimeout;
12701311
bool hadConfigData = false;
1312+
bool hadDynamicData = false;
12711313

12721314
bool isForcedConfigPortal = false;
12731315
bool persForcedConfigPortal = false;
@@ -1653,6 +1695,11 @@ class ESP_WiFiManager_Lite
16531695

16541696
bool loadDynamicData()
16551697
{
1698+
if (hadDynamicData)
1699+
{
1700+
return true;
1701+
}
1702+
16561703
int checkSum = 0;
16571704
int readCheckSum;
16581705
totalDataSize = sizeof(ESP_WM_LITE_config) + sizeof(readCheckSum);
@@ -1705,6 +1752,7 @@ class ESP_WiFiManager_Lite
17051752
return false;
17061753
}
17071754

1755+
hadDynamicData = true;
17081756
return true;
17091757
}
17101758

0 commit comments

Comments
 (0)