Init Shared Repo
This commit is contained in:
40
src/main.cpp
Normal file
40
src/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "SPIFFS.h"
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
if (!SPIFFS.begin(true)) {
|
||||
Serial.println("An Error has occurred while mounting SPIFFS");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = SPIFFS.open("/test.txt", FILE_WRITE);
|
||||
|
||||
if (!file) {
|
||||
Serial.println("There was an error opening the file for writing");
|
||||
return;
|
||||
}
|
||||
if (file.print("TEST1\nTEST2\nTEST3")) {
|
||||
Serial.println("File was written");
|
||||
} else {
|
||||
Serial.println("File write failed");
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
file = SPIFFS.open("/test.txt", FILE_READ);
|
||||
String content;
|
||||
|
||||
Serial.println("COTENTS OF FILE:");
|
||||
while(file.available()) {
|
||||
content = file.readStringUntil('\n');
|
||||
Serial.println(content);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Serial.println("File end");
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
Reference in New Issue
Block a user