Make card write atomic and don't arm unless LED state is off
This commit is contained in:
parent
2c9542a2bc
commit
ffcfb54aa9
|
@ -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…
Reference in New Issue
Block a user