You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
// we could open the file
size_t size = f.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
// Read and store file contents in buf
f.readBytes(buf.get(), size);
I get rubish in buf, i had to rewrite like this to be able to read by SPIFF file:
File f = SPIFFS.open(CONFIG_FILE, "r");
String buffer; /// Create a string buffer to get the file contents
//
Serial.println("Get file");
if (!f) Serial.println("FAIL TO LOAD FILE");
while (f.available()){
buffer = f.readString().c_str();
}
Serial.print("file buffer: ");Serial.println(String(buffer)); // Print buffer which contains file contents
char * doc = new char [buffer.length()+1]; // Define a pointer to a char buffer called doc
std::strcpy (doc, buffer.c_str()); // Copy string buffer to char buffer caled doc
Serial.print("doc: ");Serial.println(String(doc)); // Print doc as string
// Do the joson stuff
StaticJsonDocument<1024> json;
Serial.println("deserialize !");
of course add this in a header file:
// strings and c-strings
#include
#include
#include