diff --git a/lib/mfrc522/source/loop.php b/lib/mfrc522/source/loop.php index 5956fb0..521d99f 100755 --- a/lib/mfrc522/source/loop.php +++ b/lib/mfrc522/source/loop.php @@ -36,8 +36,6 @@ $state = preg_replace('@^\s+@', '', $state); $state = preg_replace('@\s+$@', '', $state); - var_dump($state); - /* (3) Check data */ if( strlen($state) < 1 ) return false; @@ -115,6 +113,10 @@ /* (5) Update global state */ $state = get_gstate(); + // manage error + if( $state === false ) + return false; + /* [2] Manage timeout =========================================================*/ @@ -298,19 +300,14 @@ /* [3] Check global state =========================================================*/ /* (1) Check file */ - $gstate = $f_gstate->current(); + $gstate = get_gstate(); - if( !$gstate ) + /* (2) Manage error */ + if( $gstate === false ) return 127; - /* (3) Remove surrounding spaces */ - $gstate = preg_replace('@^\s+@', '', $gstate); - $gstate = preg_replace('@\s+$@', '', $gstate); - /* (4) Manage error */ - if( strlen($gstate) < 1 ) - return 127; - + return 0; } @@ -329,6 +326,13 @@ /* (2) Caches */ global $actions; + /* (3) Get global state */ + $gstate = get_gstate(); + + // Manage error + if( $gstate === false ) + return false; + /* [1] Wait for rfid card @@ -394,10 +398,10 @@ // {2} If not updated -> error // if( !$updateds ) - slog("Cannot update chips to '".get_gstate()."'", 'mfrc522:loop'); + slog("Cannot update chips to '{$gstate}'", 'mfrc522:loop'); // {3} If updated -> success // else - slog("Chips updated to ".get_gstate()."'", 'mfrc522:loop'); + slog("Chips updated to '{$gstate}'", 'mfrc522:loop'); /* (3) If not performed -> log error */ }else