Skip to content

Commit

Permalink
Full restart on factory reset, increment bootcount to match filesystem (
Browse files Browse the repository at this point in the history
#160)

Closes #152 by performing ESP.restart() during factory reset
Closes #154 by incrementing bootcount when a colliding filename is detected
  • Loading branch information
JosephHewitt authored Jun 30, 2024
1 parent eed1e66 commit 6f73271
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions A/A.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ void boot_config(){
display.display();
preferences.clear();
delay(2000);
firstrun = true;
ESP.restart();
}

if (!firstrun && !block_resets){
Expand Down Expand Up @@ -2419,9 +2419,24 @@ void setup() {

Serial.println("Opening destination file for writing");

String filename = "/wd3-";
filename = filename + bootcount;
filename = filename + ".csv";
String filename = "";
while (filename == "" || SD.exists(filename)){
filename = "/wd3-";
filename = filename + bootcount;
filename = filename + ".csv";
if (SD.exists(filename)){
Serial.print("File already exists at ");
Serial.print(filename);
bootcount++;
filename = "";
preferences.begin("wardriver", false);
preferences.putULong("bootcount", bootcount);
preferences.end();
Serial.print("Incremented bootcount to ");
Serial.println(bootcount);
}
}
Serial.print("Opening file for main session: ");
Serial.println(filename);
filewriter = SD.open(filename, FILE_APPEND);

Expand Down

0 comments on commit 6f73271

Please sign in to comment.