From 1e9ca2389042c8e160ba2904cc0d5b8cd48b0ab3 Mon Sep 17 00:00:00 2001 From: thoaitrieu Date: Sat, 13 Jan 2018 17:00:58 +0700 Subject: [PATCH] Fix AccessControl.ino (#353) * Fix AccessControl.ino The function checkTwo not work with some cards with 0-index key ID equals to 0 not found in storeCard..then they add fullstack of the same card. --- examples/AccessControl/AccessControl.ino | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/AccessControl/AccessControl.ino b/examples/AccessControl/AccessControl.ino index 75b402e..8facd75 100644 --- a/examples/AccessControl/AccessControl.ino +++ b/examples/AccessControl/AccessControl.ino @@ -429,19 +429,13 @@ void deleteID( byte a[] ) { } ///////////////////////////////////////// Check Bytes /////////////////////////////////// -boolean checkTwo ( byte a[], byte b[] ) { - if ( a[0] != 0 ) // Make sure there is something in the array first - match = true; // Assume they match at first +boolean checkTwo ( byte a[], byte b[] ) { for ( uint8_t k = 0; k < 4; k++ ) { // Loop 4 times - if ( a[k] != b[k] ) // IF a != b then set match = false, one fails, all fail - match = false; - } - if ( match ) { // Check to see if if match is still true - return true; // Return true - } - else { - return false; // Return false + if ( a[k] != b[k] ) { // IF a != b then set match = false, one fails, all fail + return false; + } } + return true; } ///////////////////////////////////////// Find Slot ///////////////////////////////////