basics of factory reset implemented
This commit is contained in:
parent
3f8b060c66
commit
4c57546657
2 changed files with 41 additions and 7 deletions
|
@ -63,6 +63,9 @@
|
|||
|
||||
|
||||
void setup() {
|
||||
// define output for onboard LED/WIPE pin
|
||||
pinMode(PinWIPE, OUTPUT);
|
||||
|
||||
// Start Serial
|
||||
Serial.begin(115200);
|
||||
|
||||
|
@ -75,14 +78,37 @@ void setup() {
|
|||
Serial.print(CanGrowBuild);
|
||||
Serial.println(" starting ::.");
|
||||
|
||||
|
||||
Serial.print(":: To format LittleFS, pull ");
|
||||
Serial.print(PinWIPE);
|
||||
Serial.println("(PinWIPE) to LOW - NOW! (2 seconds left) ::");
|
||||
|
||||
// blink with the onboard LED on D4 (PinWIPE)
|
||||
for(byte i = 0; i <= 6 ; i++) {
|
||||
if(i % 2) {
|
||||
digitalWrite(PinWIPE, LOW);
|
||||
} else {
|
||||
digitalWrite(PinWIPE, HIGH);
|
||||
}
|
||||
delay(333);
|
||||
}
|
||||
// set back to HIGH because thats the default
|
||||
digitalWrite(PinWIPE, HIGH);
|
||||
//delay(2000);
|
||||
|
||||
// read status from PinWIPE to WIPE
|
||||
// when PinWIPE is set to LOW, format LittleFS
|
||||
if(digitalRead(PinWIPE) == LOW) {
|
||||
Serial.println("!! formatting LittleFS !!");
|
||||
LittleFS.format();
|
||||
}
|
||||
|
||||
|
||||
Serial.println(":: initialise LittleFS ::");
|
||||
if(LittleFS.begin()) {
|
||||
Serial.println(":: LittleFS successfully initialized ::");
|
||||
Serial.println(":: LittleFS successfully initialised ::");
|
||||
} else {
|
||||
Serial.println("!! LittleFS failed initializing !!");
|
||||
delay(10000);
|
||||
LittleFS.format();
|
||||
Serial.println("!! formatting LittleFS !!");
|
||||
Serial.println("!! LittleFS failed initialising !!");
|
||||
}
|
||||
|
||||
// read the configfile from LittleFS
|
||||
|
@ -93,14 +119,14 @@ void setup() {
|
|||
if(lfs_configfile) {
|
||||
Serial.println(":: LittleFS: config.json successfully created ::");
|
||||
// write into the file
|
||||
lfs_configfile.print("{}");
|
||||
lfs_configfile.print("{test: 2}");
|
||||
// close the file
|
||||
lfs_configfile.close();
|
||||
}
|
||||
} else {
|
||||
Serial.println(":: LittleFS: config.json successfully opened ::");
|
||||
String configfile_content = "";
|
||||
Serial.println(lfs_configfile.available());
|
||||
|
||||
while (lfs_configfile.available()) {
|
||||
configfile_content += (char)lfs_configfile.read();
|
||||
}
|
||||
|
|
|
@ -31,3 +31,11 @@
|
|||
|
||||
|
||||
const char* configfile = "config.json";
|
||||
|
||||
#ifdef ESP8266
|
||||
const uint8_t PinWIPE = D4;
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
const uint8_t PinWIPE = 2;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue