This commit is contained in:
xdrm-brackets 2017-02-23 14:47:25 +01:00
parent 07b61d2167
commit cd2ae5fd9c
2 changed files with 21 additions and 4 deletions

Binary file not shown.

View File

@ -248,7 +248,7 @@
continue; continue;
/* (3) Add key (timeout) to cache */ /* (3) Add key (timeout) to cache */
if( !isset($actions[$parsed[0]] ) if( !isset($actions[$parsed[0]]) )
$actions[$parsed[0]] = []; $actions[$parsed[0]] = [];
/* (4) Add entry to cache */ /* (4) Add entry to cache */
@ -290,7 +290,7 @@
=========================================================*/ =========================================================*/
/* (1) Check file */ /* (1) Check file */
if( $f_gstate === false ) if( $f_gstate === false )
return; return false;
/* (2) Remove surrounding spaces */ /* (2) Remove surrounding spaces */
$f_gstate = preg_replace('@^\s+@', '', $f_gstate); $f_gstate = preg_replace('@^\s+@', '', $f_gstate);
@ -300,7 +300,7 @@
for( $c = 0 ; $c < strlen($f_gstate) ; $c++ ) for( $c = 0 ; $c < strlen($f_gstate) ; $c++ )
$state[] = $c; $state[] = $c;
return true;
} }
@ -323,7 +323,7 @@
/* [1] Wait for rfid card /* [1] Wait for rfid card
=========================================================*/ =========================================================*/
/* (1) Read 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 */ /* (2) If no card read -> reset @last_user / @timeout + abort */
if( $code === false ){ if( $code === false ){
@ -351,6 +351,7 @@
/* (2) If not found -> reset @last_user / @timeout + abort */ /* (2) If not found -> reset @last_user / @timeout + abort */
if( is_null($user) ){ if( is_null($user) ){
slog("Unknown user (not authenticated)", "mfrc522:loop");
$last_user = null; $last_user = null;
$timeout = 0; $timeout = 0;
return false; 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'); slog('daemon started (loop)', 'mfrc522:loop');
/* [2] Daemon loop
=========================================================*/
while( true ){ while( true ){
$start_ts = microtime(true); $start_ts = microtime(true);