diff --git a/lib/mfrc522/source/.loop.php.swp b/lib/mfrc522/source/.loop.php.swp deleted file mode 100644 index 8bdfea5..0000000 Binary files a/lib/mfrc522/source/.loop.php.swp and /dev/null differ diff --git a/lib/mfrc522/source/loop.php b/lib/mfrc522/source/loop.php index 03f4776..56018ff 100755 --- a/lib/mfrc522/source/loop.php +++ b/lib/mfrc522/source/loop.php @@ -248,7 +248,7 @@ continue; /* (3) Add key (timeout) to cache */ - if( !isset($actions[$parsed[0]] ) + if( !isset($actions[$parsed[0]]) ) $actions[$parsed[0]] = []; /* (4) Add entry to cache */ @@ -290,7 +290,7 @@ =========================================================*/ /* (1) Check file */ if( $f_gstate === false ) - return; + return false; /* (2) Remove surrounding spaces */ $f_gstate = preg_replace('@^\s+@', '', $f_gstate); @@ -300,7 +300,7 @@ for( $c = 0 ; $c < strlen($f_gstate) ; $c++ ) $state[] = $c; - + return true; } @@ -323,7 +323,7 @@ /* [1] Wait for rfid card =========================================================*/ /* (1) Read card */ - $code = syscall(SOURCE_DIR.'/lib/mfrc522/read')); + $code = syscall(SOURCE_DIR.'/lib/mfrc522/read'); /* (2) If no card read -> reset @last_user / @timeout + abort */ if( $code === false ){ @@ -351,6 +351,7 @@ /* (2) If not found -> reset @last_user / @timeout + abort */ if( is_null($user) ){ + slog("Unknown user (not authenticated)", "mfrc522:loop"); $last_user = null; $timeout = 0; return false; @@ -404,10 +405,26 @@ + /* [1] Set up daemon + =========================================================*/ + /* (1) Set up */ + $exec = mfrc522_setup(); + /* (2) Manage error */ + if( $exec === false ){ + slog('cannot set up the daemon', 'mfrc522:loop'); + echo $exec; + die($exec); + } + /* (3) Success message */ slog('daemon started (loop)', 'mfrc522:loop'); + + + + /* [2] Daemon loop + =========================================================*/ while( true ){ $start_ts = microtime(true);