Skip to content

Instantly share code, notes, and snippets.

@msraynsford
Created March 12, 2018 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msraynsford/fd9416512434f7748587927f86741d35 to your computer and use it in GitHub Desktop.
Save msraynsford/fd9416512434f7748587927f86741d35 to your computer and use it in GitHub Desktop.
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
//Activate the EEPROM before attempting to use it
EEPROM.begin(sizeof(flag));
//Check to see if the flag is still set from the previous boot
if(checkFlag()) {
//Clear the flag now it has been detected
writeFlag(FLAGCLEAR);
//Do the firmware reset here
Serial.println("Flag Detected");
digitalWrite(LED_BUILTIN, LOW);
}
else {
//Set the flag for detection with the next boot
writeFlag(FLAGSET);
}
// After setup, while away the end of the reset period
while (millis() < FLAGTIMEOUT);
writeFlag(FLAGCLEAR);
Serial.println("Flag Checking Stopped");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment