Skip to content

Commit ff191ac

Browse files
committed
removed unused function checkDynamicData()
1 parent 0bc8029 commit ff191ac

File tree

1 file changed

+0
-150
lines changed

1 file changed

+0
-150
lines changed

src/ESP_WiFiManager_Lite.h

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,96 +1683,6 @@ class ESP_WiFiManager_Lite
16831683

16841684
#if USE_DYNAMIC_PARAMETERS
16851685

1686-
bool checkDynamicData()
1687-
{
1688-
int checkSum = 0;
1689-
int readCheckSum;
1690-
char* readBuffer;
1691-
1692-
File file = FileFS.open(CREDENTIALS_FILENAME, "r");
1693-
ESP_WML_LOGINFO(F("LoadCredFile "));
1694-
1695-
if (!file)
1696-
{
1697-
ESP_WML_LOGINFO(F("failed"));
1698-
1699-
// Trying open redundant config file
1700-
file = FileFS.open(CREDENTIALS_FILENAME_BACKUP, "r");
1701-
ESP_WML_LOGINFO(F("LoadBkUpCredFile "));
1702-
1703-
if (!file)
1704-
{
1705-
ESP_WML_LOGINFO(F("failed"));
1706-
return false;
1707-
}
1708-
}
1709-
1710-
// Find the longest pdata, then dynamically allocate buffer. Remember to free when done
1711-
// This is used to store tempo data to calculate checksum to see of data is valid
1712-
// We dont like to destroy myMenuItems[i].pdata with invalid data
1713-
1714-
uint16_t maxBufferLength = 0;
1715-
1716-
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
1717-
{
1718-
if (myMenuItems[i].maxlen > maxBufferLength)
1719-
maxBufferLength = myMenuItems[i].maxlen;
1720-
}
1721-
1722-
if (maxBufferLength > 0)
1723-
{
1724-
readBuffer = new char[ maxBufferLength + 1 ];
1725-
1726-
// check to see NULL => stop and return false
1727-
if (readBuffer == NULL)
1728-
{
1729-
ESP_WML_LOGERROR(F("ChkCrR: Error can't allocate buffer."));
1730-
return false;
1731-
}
1732-
else
1733-
{
1734-
ESP_WML_LOGDEBUG1(F("ChkCrR: Buffer allocated, sz="), maxBufferLength + 1);
1735-
}
1736-
1737-
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
1738-
{
1739-
char* _pointer = readBuffer;
1740-
1741-
// Actual size of pdata is [maxlen + 1]
1742-
memset(readBuffer, 0, myMenuItems[i].maxlen + 1);
1743-
1744-
file.readBytes(_pointer, myMenuItems[i].maxlen);
1745-
1746-
ESP_WML_LOGDEBUG3(F("ChkCrR:pdata="), readBuffer, F(",len="), myMenuItems[i].maxlen);
1747-
1748-
for (uint16_t j = 0; j < myMenuItems[i].maxlen; j++, _pointer++)
1749-
{
1750-
checkSum += *_pointer;
1751-
}
1752-
}
1753-
1754-
file.readBytes((char *) &readCheckSum, sizeof(readCheckSum));
1755-
1756-
ESP_WML_LOGINFO(F("OK"));
1757-
file.close();
1758-
1759-
ESP_WML_LOGINFO3(F("CrCCsum=0x"), String(checkSum, HEX), F(",CrRCsum=0x"), String(readCheckSum, HEX));
1760-
1761-
// Free buffer
1762-
delete [] readBuffer;
1763-
ESP_WML_LOGDEBUG(F("Buffer freed"));
1764-
1765-
if ( checkSum == readCheckSum)
1766-
{
1767-
return true;
1768-
}
1769-
}
1770-
1771-
return false;
1772-
}
1773-
1774-
//////////////////////////////////////////////
1775-
17761686
bool loadDynamicData()
17771687
{
17781688
if (hadDynamicData)
@@ -2256,66 +2166,6 @@ class ESP_WiFiManager_Lite
22562166

22572167
#if USE_DYNAMIC_PARAMETERS
22582168

2259-
bool checkDynamicData()
2260-
{
2261-
int checkSum = 0;
2262-
int readCheckSum;
2263-
2264-
#define BUFFER_LEN 128
2265-
char readBuffer[BUFFER_LEN + 1];
2266-
2267-
uint16_t offset = CONFIG_EEPROM_START + sizeof(ESP_WM_LITE_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE;
2268-
2269-
// Find the longest pdata, then dynamically allocate buffer. Remember to free when done
2270-
// This is used to store tempo data to calculate checksum to see of data is valid
2271-
// We dont like to destroy myMenuItems[i].pdata with invalid data
2272-
2273-
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
2274-
{
2275-
if (myMenuItems[i].maxlen > BUFFER_LEN)
2276-
{
2277-
// Size too large, abort and flag false
2278-
ESP_WML_LOGERROR(F("ChkCrR: Error Small Buffer."));
2279-
return false;
2280-
}
2281-
}
2282-
2283-
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
2284-
{
2285-
char* _pointer = readBuffer;
2286-
2287-
// Prepare buffer, more than enough
2288-
memset(readBuffer, 0, sizeof(readBuffer));
2289-
2290-
// Read more than necessary, but OK and easier to code
2291-
EEPROM.get(offset, readBuffer);
2292-
// NULL terminated
2293-
readBuffer[myMenuItems[i].maxlen] = 0;
2294-
2295-
ESP_WML_LOGDEBUG3(F("ChkCrR:pdata="), readBuffer, F(",len="), myMenuItems[i].maxlen);
2296-
2297-
for (uint16_t j = 0; j < myMenuItems[i].maxlen; j++, _pointer++)
2298-
{
2299-
checkSum += *_pointer;
2300-
}
2301-
2302-
offset += myMenuItems[i].maxlen;
2303-
}
2304-
2305-
EEPROM.get(offset, readCheckSum);
2306-
2307-
ESP_WML_LOGINFO3(F("ChkCrR:CrCCsum=0x"), String(checkSum, HEX), F(",CrRCsum=0x"), String(readCheckSum, HEX));
2308-
2309-
if ( checkSum != readCheckSum)
2310-
{
2311-
return false;
2312-
}
2313-
2314-
return true;
2315-
}
2316-
2317-
//////////////////////////////////////////////
2318-
23192169
bool EEPROM_getDynamicData()
23202170
{
23212171
if (hadDynamicData)

0 commit comments

Comments
 (0)