Append newline to config.json and add file debug

This commit is contained in:
aderusha 2021-11-15 16:04:14 -05:00
parent 16a5695621
commit efd785a458
3 changed files with 22 additions and 0 deletions

View File

@ -2158,6 +2158,7 @@ void configRead()
if (SPIFFS.exists("/config.json"))
{ // File exists, reading and loading
debugPrintln(F("SPIFFS: reading /config.json"));
debugPrintFile("/config.json");
File configFile = SPIFFS.open("/config.json", "r");
if (configFile)
{
@ -2376,9 +2377,11 @@ void configSave()
else
{
serializeJson(jsonConfigValues, configFile);
configFile.println("");
yield();
configFile.close();
}
debugPrintFile("/config.json");
shouldSaveConfig = false;
}
@ -3681,6 +3684,25 @@ void debugPrintCrash()
SaveCrash.clear();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void debugPrintFile(const String &fileName)
{ // Debug output line of text to our debug targets
File debugFile = SPIFFS.open(fileName, "r");
if (debugFile)
{
uint16_t lineCount = 1;
while (debugFile.available())
{
debugPrintln(F("SPIFFS: file:") + fileName + F(" line:") + String(lineCount) + F(" data:")+ debugFile.readStringUntil('\n'));
lineCount++;
}
debugFile.close();
}
else {
debugPrintln("SPIFFS: Error opening file for read: " + fileName);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Submitted by benmprojects to handle "beep" commands. Split
// incoming String by separator, return selected field as String