From 8f92cd5450fb066fc5aa56659f7e8c80d6af041a Mon Sep 17 00:00:00 2001 From: Nick Reynolds Date: Wed, 22 May 2024 12:50:13 +0100 Subject: [PATCH] Improve behaviour for failed cards and PINs when they are fitted and unused. --- src/LarpHackableRfidLock.cpp | 11 +++++++---- src/LarpHackableRfidLock.h | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/LarpHackableRfidLock.cpp b/src/LarpHackableRfidLock.cpp index 49b1be0..3f24c8f 100644 --- a/src/LarpHackableRfidLock.cpp +++ b/src/LarpHackableRfidLock.cpp @@ -456,7 +456,7 @@ bool ICACHE_FLASH_ATTR LarpHackableRfidLock::loadConfiguration(const char* filen tap_code_revoke_ = doc[tap_code_revoke_key_] | tap_code_revoke_default_; tap_code_revoke_all_ = doc[tap_code_revoke_all_key_] | tap_code_revoke_all_default_; //PIN codes - pin_entry_enabled_ == doc[pin_entry_enabled_key_]; + pin_entry_enabled_ = doc[pin_entry_enabled_key_] | pin_entry_enabled_default_; pin_to_open_ = doc[pin_to_open_key_] | pin_to_open_default_; pin_to_seal_ = doc[pin_to_seal_key_] | pin_to_seal_default_; pin_to_unseal_ = doc[pin_to_unseal_key_] | pin_to_unseal_default_; @@ -700,7 +700,7 @@ bool ICACHE_FLASH_ATTR LarpHackableRfidLock::saveConfiguration(const char* filen doc[tap_code_revoke_key_] = tap_code_revoke_; doc[tap_code_revoke_all_key_] = tap_code_revoke_all_; //PIN codes - //doc[pin_entry_enabled_key_] = pin_entry_enabled_; + doc[pin_entry_enabled_key_] = pin_entry_enabled_; doc[pin_to_open_key_] = pin_to_open_; doc[pin_to_seal_key_] = pin_to_seal_; doc[pin_to_unseal_key_] = pin_to_unseal_; @@ -1043,7 +1043,7 @@ void ICACHE_FLASH_ATTR LarpHackableRfidLock::housekeeping(){ #ifdef HOUSEKEEPING_DEBUG Serial.println(housekeepingdebug++); //8 #endif - if(rfid_reader_intialised_ == true && rfid_ != nullptr) { //Only run the RFID reader code if enabled + if(rfid_authorisation_enabled_ == true && rfid_reader_intialised_ == true && rfid_ != nullptr) { //Only run the RFID reader code if enabled and initialised rfid_->pollForCard(); } //Manage TapCode @@ -1212,7 +1212,8 @@ void ICACHE_FLASH_ATTR LarpHackableRfidLock::housekeeping(){ #ifdef HOUSEKEEPING_DEBUG Serial.println(housekeepingdebug++); //15 #endif - if(pinEntered()) { //Check if a pin has been entered and clear if it has + //Check for entered pins from the matrix + if(pin_entered_ == true && millis() - last_pin_entry_ > 250) { //Check if a pin has been entered and clear if it has if(pin_entry_enabled_ == true) { if(pin_to_open_.length() != 0 && pinMatches(pin_to_open_)) { //PIN matches the 'open' one if(multi_factor_enabled_ == true) { @@ -1267,6 +1268,8 @@ void ICACHE_FLASH_ATTR LarpHackableRfidLock::housekeeping(){ } else { //Deny access deny(); } + } else { //Deny access + deny(); } clearEnteredPin(); } diff --git a/src/LarpHackableRfidLock.h b/src/LarpHackableRfidLock.h index 8a4e510..3e7dbf3 100644 --- a/src/LarpHackableRfidLock.h +++ b/src/LarpHackableRfidLock.h @@ -650,7 +650,8 @@ class LarpHackableRfidLock { char lock_access_group_key_[9] = "accessId"; uint8_t lock_access_group_default_ = 0; //Is PIN entry enabled - bool pin_entry_enabled_ = true; + bool pin_entry_enabled_ = false; + bool pin_entry_enabled_default_ = false; String pin_entry_enabled_key_ = "pin_entry_enabled_"; String pin_to_open_ = ""; String pin_to_open_key_ = "pin_to_open_";