@@ -1328,7 +1328,10 @@ class ESP_WiFiManager_Lite
1328
1328
1329
1329
#else // #if ( USE_LITTLEFS || USE_SPIFFS )
1330
1330
1331
- return EEPROM_getDynamicData ();
1331
+ EEPROM.begin (EEPROM_SIZE);
1332
+ bool valid = EEPROM_getDynamicData ();
1333
+ EEPROM.end ();
1334
+ return valid;
1332
1335
1333
1336
#endif // #if ( USE_LITTLEFS || USE_SPIFFS )
1334
1337
}
@@ -1355,7 +1358,9 @@ class ESP_WiFiManager_Lite
1355
1358
1356
1359
#else // #if ( USE_LITTLEFS || USE_SPIFFS )
1357
1360
1361
+ EEPROM.begin (EEPROM_SIZE);
1358
1362
EEPROM_putDynamicData ();
1363
+ EEPROM.end ();
1359
1364
1360
1365
#endif // #if ( USE_LITTLEFS || USE_SPIFFS )
1361
1366
}
@@ -2313,10 +2318,32 @@ class ESP_WiFiManager_Lite
2313
2318
2314
2319
bool EEPROM_getDynamicData ()
2315
2320
{
2321
+ if (hadDynamicData)
2322
+ {
2323
+ return true ;
2324
+ }
2325
+
2316
2326
int readCheckSum;
2317
2327
int checkSum = 0 ;
2318
2328
uint16_t offset = CONFIG_EEPROM_START + sizeof (ESP_WM_LITE_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE;
2319
2329
2330
+ // calculate ckecksum first, before overwriting myMenuItems buffer
2331
+ for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
2332
+ {
2333
+ for (uint16_t j = 0 ; j < myMenuItems[i].maxlen ; j++, offset++)
2334
+ {
2335
+ checkSum += EEPROM.read (offset);
2336
+ }
2337
+ }
2338
+ EEPROM.get (offset, readCheckSum);
2339
+ ESP_WML_LOGINFO3 (F (" CrCCsum=0x" ), String (checkSum, HEX), F (" ,CrRCsum=0x" ), String (readCheckSum, HEX));
2340
+
2341
+ if (checkSum != readCheckSum)
2342
+ {
2343
+ return false ;
2344
+ }
2345
+
2346
+ offset = CONFIG_EEPROM_START + sizeof (ESP_WM_LITE_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE;
2320
2347
totalDataSize = sizeof (ESP_WM_LITE_config) + sizeof (readCheckSum);
2321
2348
2322
2349
for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
@@ -2330,22 +2357,12 @@ class ESP_WiFiManager_Lite
2330
2357
for (uint16_t j = 0 ; j < myMenuItems[i].maxlen ; j++, _pointer++, offset++)
2331
2358
{
2332
2359
*_pointer = EEPROM.read (offset);
2333
-
2334
- checkSum += *_pointer;
2335
2360
}
2336
2361
2337
2362
ESP_WML_LOGDEBUG3 (F (" CR:pdata=" ), myMenuItems[i].pdata , F (" ,len=" ), myMenuItems[i].maxlen );
2338
2363
}
2339
2364
2340
- EEPROM.get (offset, readCheckSum);
2341
-
2342
- ESP_WML_LOGINFO3 (F (" CrCCsum=0x" ), String (checkSum, HEX), F (" ,CrRCsum=0x" ), String (readCheckSum, HEX));
2343
-
2344
- if ( checkSum != readCheckSum)
2345
- {
2346
- return false ;
2347
- }
2348
-
2365
+ hadDynamicData = true ;
2349
2366
return true ;
2350
2367
}
2351
2368
@@ -2505,30 +2522,10 @@ class ESP_WiFiManager_Lite
2505
2522
strcpy (ESP_WM_LITE_config.WiFi_Creds [1 ].wifi_ssid , WM_NO_CONFIG);
2506
2523
strcpy (ESP_WM_LITE_config.WiFi_Creds [1 ].wifi_pw , WM_NO_CONFIG);
2507
2524
strcpy (ESP_WM_LITE_config.board_name , WM_NO_CONFIG);
2508
-
2509
- #if USE_DYNAMIC_PARAMETERS
2510
-
2511
- for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
2512
- {
2513
- // Actual size of pdata is [maxlen + 1]
2514
- memset (myMenuItems[i].pdata , 0 , myMenuItems[i].maxlen + 1 );
2515
- strncpy (myMenuItems[i].pdata , WM_NO_CONFIG, myMenuItems[i].maxlen );
2516
- }
2517
-
2518
- #endif
2519
2525
}
2520
2526
2521
2527
strcpy (ESP_WM_LITE_config.header , ESP_WM_LITE_BOARD_TYPE);
2522
2528
2523
- #if USE_DYNAMIC_PARAMETERS
2524
-
2525
- for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
2526
- {
2527
- ESP_WML_LOGDEBUG3 (F (" g:myMenuItems[" ), i, F (" ]=" ), myMenuItems[i].pdata );
2528
- }
2529
-
2530
- #endif
2531
-
2532
2529
saveAllConfigData ();
2533
2530
displayConfigData (ESP_WM_LITE_config);
2534
2531
@@ -2678,7 +2675,7 @@ class ESP_WiFiManager_Lite
2678
2675
ListOfSSIDs = String (FPSTR (ESP_WM_LITE_OPTION_START)) + String (FPSTR (ESP_WM_LITE_NO_NETWORKS_FOUND)) + String (FPSTR (ESP_WM_LITE_OPTION_END));
2679
2676
2680
2677
pitem = FPSTR (ESP_WM_LITE_HTML_HEAD_END);
2681
-
2678
+ ESP_WML_LOGERROR3 ( " 1 pitem.capacity(): " , String (pitem. capacity ()), " pitem.length(): " , String (pitem. length ())); // TODO
2682
2679
#if MANUAL_SSID_INPUT_ALLOWED
2683
2680
pitem.replace (" [[input_id]]" , " <input id='id' list='SSIDs'>" + String (FPSTR (ESP_WM_LITE_DATALIST_START)) + " 'SSIDs'>" +
2684
2681
ListOfSSIDs + FPSTR (ESP_WM_LITE_DATALIST_END));
@@ -2687,8 +2684,10 @@ class ESP_WiFiManager_Lite
2687
2684
ListOfSSIDs + FPSTR (ESP_WM_LITE_DATALIST_END));
2688
2685
ESP_WML_LOGDEBUG1 (F (" pitem:" ), pitem);
2689
2686
#else
2690
- pitem.replace (" [[input_id]]" , " <select id='id'>" + ListOfSSIDs + FPSTR (ESP_WM_LITE_SELECT_END));
2691
- pitem.replace (" [[input_id1]]" , " <select id='id1'>" + ListOfSSIDs + FPSTR (ESP_WM_LITE_SELECT_END));
2687
+ pitem.replace (F (" [[input_id]]" ), F (" <select id='id'>" ) + ListOfSSIDs + String (FPSTR (ESP_WM_LITE_SELECT_END)));
2688
+ ESP_WML_LOGERROR3 (" 2 pitem.capacity():" , String (pitem.capacity ()), " pitem.length():" , String (pitem.length ())); // TODO
2689
+ pitem.replace (F (" [[input_id1]]" ), F (" <select id='id1'>" ) + ListOfSSIDs + String (FPSTR (ESP_WM_LITE_SELECT_END)));
2690
+ ESP_WML_LOGERROR3 (" 3 pitem.capacity():" , String (pitem.capacity ()), " pitem.length():" , String (pitem.length ())); // TODO
2692
2691
#endif
2693
2692
2694
2693
root_html_template += pitem + FPSTR (ESP_WM_LITE_FLDSET_START);
@@ -2707,10 +2706,12 @@ class ESP_WiFiManager_Lite
2707
2706
for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
2708
2707
{
2709
2708
pitem = FPSTR (ESP_WM_LITE_HTML_PARAM);
2709
+ ESP_WML_LOGERROR3 (" 4 pitem.capacity():" , String (pitem.capacity ()), " pitem.length():" , String (pitem.length ())); // TODO
2710
2710
2711
2711
pitem.replace (" {b}" , myMenuItems[i].displayName );
2712
2712
pitem.replace (" {v}" , myMenuItems[i].id );
2713
2713
pitem.replace (" {i}" , myMenuItems[i].id );
2714
+ ESP_WML_LOGERROR3 (" 5 pitem.capacity():" , String (pitem.capacity ()), " pitem.length():" , String (pitem.length ())); // TODO
2714
2715
2715
2716
root_html_template += pitem;
2716
2717
}
@@ -2724,6 +2725,7 @@ class ESP_WiFiManager_Lite
2724
2725
for (uint16_t i = 0 ; i < NUM_MENU_ITEMS; i++)
2725
2726
{
2726
2727
pitem = FPSTR (ESP_WM_LITE_HTML_SCRIPT_ITEM);
2728
+ ESP_WML_LOGERROR3 (" 6 pitem.capacity():" , String (pitem.capacity ()), " pitem.length():" , String (pitem.length ())); // TODO
2727
2729
2728
2730
pitem.replace (" {d}" , myMenuItems[i].id );
2729
2731
@@ -2732,7 +2734,9 @@ class ESP_WiFiManager_Lite
2732
2734
2733
2735
#endif
2734
2736
2737
+ ESP_WML_LOGERROR3 (" 7 root_html_template.capacity():" , String (root_html_template.capacity ()), " root_html_template.length():" , String (root_html_template.length ())); // TODO
2735
2738
root_html_template += String (FPSTR (ESP_WM_LITE_HTML_SCRIPT_END)) + FPSTR (ESP_WM_LITE_HTML_END);
2739
+ ESP_WML_LOGERROR3 (" 8 root_html_template.capacity():" , String (root_html_template.capacity ()), " root_html_template.length():" , String (root_html_template.length ())); // TODO
2736
2740
2737
2741
return ;
2738
2742
}
0 commit comments