Make card write atomic and don't arm unless LED state is off

master
Tanner Collin 5 years ago
parent 2c9542a2bc
commit ffcfb54aa9
  1. 4
      firmware/firmware.ino

@ -403,7 +403,7 @@ void postState()
if (LOGGING) Serial.println(lockPayload);
String action = deserializeLockJson(lockPayload);
if (action == "arm" && lockState == LOCK_OFF) {
if (action == "arm" && lockState == LOCK_OFF && LEDState == LED_OFF) {
lockState = LOCK_PREARM;
} else if (action == "disarm") {
lockState = LOCK_OFF;
@ -442,11 +442,13 @@ void getCards()
cardPayload += "$"; // Mark the end
if (LOGGING) Serial.println(cardPayload);
noInterrupts(); // commit() disables interrupts, but we want an atomic EEPROM buffer write
for (int i = 0; i < cardPayload.length(); i++) {
if (i >= EEPROM_SIZE) break;
EEPROM.write(i, cardPayload.charAt(i));
}
EEPROM.commit();
interrupts();
if (LOGGING) Serial.println("[INFO] Finished getting card data.");
} else {

Loading…
Cancel
Save