diff --git a/feature/rfid-read/source/loop.php b/feature/rfid-read/source/loop.php index 22706f3..f3bb4ff 100755 --- a/feature/rfid-read/source/loop.php +++ b/feature/rfid-read/source/loop.php @@ -127,15 +127,11 @@ /* [2] Manage timeout =========================================================*/ - /* (1) If already acted for this timeout -> abort */ - if( $last_to == $cur_timeout ) - return false; - - /* (2) If no action for this @cur_timeout -> reset to 0 */ + /* (1) If no action for this @cur_timeout -> reset to 0 */ if( !isset($actions[$cur_timeout]) || !is_array($actions[$cur_timeout]) ) return false; - /* (3) fetch actions for the current @cur_timeout */ + /* (2) fetch actions for the current @cur_timeout */ $actionlist = $actions[floor($cur_timeout)]; @@ -153,7 +149,7 @@ } - /* (4) If no action found -> abort */ + /* (3) If no action found -> abort */ if( count($grantedFor) == 0 ){ slog('user not granted to any action', 'rfid-read:loop'); return false; @@ -408,10 +404,17 @@ /* [4] Manage action =========================================================*/ - /* (1) Try to process action */ + /* (1) Calc real timeout (diff in sec. between now and first time card passed) */ $cur_timeout = floor(microtime(true) - $timeout); + + /* (2) If already acted for this timeout -> abort */ + if( $last_to == $cur_timeout ) + return false; + + /* (3) Try to process action */ $performed = act($user, $cur_timeout); + /* (2) If performed -> update chip according to new state */ if( $performed ){