if (SPIFFS.begin())
{
Serial.println("Mounted File System");
if (SPIFFS.exists("/config.json"))
{
//file exists, reading and loading
Serial.println("Reading config File");
File configFile = SPIFFS.open("/config.json", "r");
if (configFile)
{
Serial.println("Opened config File");
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(buf.get());
json.printTo(Serial);
if (json.success())
{
Serial.println("\nParsed json");
strcpy(email, json["E-Mail"]);
}
else
Serial.println("Failed to Load json config");
}
}
}
else
Serial.println("Failed to Mount FS");
SPIFFS.end();
String str(email);
Serial.println("\n" + str + "\n");
I am not getting any compilation errors. It just prints junk characters sometimes. Also is it better to write data onto the EEPROM or the Flash, given I need to read the data again?
Thanks in Advance