Good day
I am close to a newbie trying to look and understand various examples.
\this one has me beat at the moment it's just related to saving and reading a config file in a Littlefs file system.
File appears to write correctly, proven by ESP32OTA which lets you read and edit the file.
however the file never reads correctly.
file appears to open correctly.
file.available reports 40 bytes before the readstring()
file.available reports 0 after the read string.
but contents of FileText string isn't changed!
There has to be a coding issue but I just cannot see it. A load of examples and documentation appear to use similar code.
thanks for reading
String readFile(String filename){
File file = LittleFS.open(filename);
if(!file){
Serial.println("Failed to open file for reading");
return "";
}
String fileText = "hello world";
Serial.printf("file contents %s\n",fileText);
while(file.available()){
Serial.printf ("file available : %i\n",file.available());
String fileText = file.readString();
Serial.printf ("file available : %i\n",file.available());
}
file.close();
Serial.printf("file contents %s\n",fileText);
return fileText;