Commit 33c571c7 authored by Mitchell Pomery's avatar Mitchell Pomery Committed by Mark Tearle
Browse files

MIFARE Reader only triggers once unless a new card is used

parent bebd1393
......@@ -390,6 +390,7 @@ def handle_getting_pin_idle(state, event, params, v, vstatus):
pass
def handle_get_selection_idle(state, event, params, v, vstatus):
global _last_card_id
# don't care right now.
###
### State logging out ..
......@@ -405,7 +406,7 @@ def handle_get_selection_idle(state, event, params, v, vstatus):
vstatus.cur_user = ''
vstatus.cur_pin = ''
vstatus.cur_selection = ''
_last_card_id = -1
reset_idler(v, vstatus)
### State fully logged out ... reset variables
......@@ -427,13 +428,14 @@ def handle_get_selection_idle(state, event, params, v, vstatus):
def handle_get_selection_key(state, event, params, v, vstatus):
global _last_card_id
key = params
if len(vstatus.cur_selection) == 0:
if key == 11:
vstatus.cur_pin = ''
vstatus.cur_user = ''
vstatus.cur_selection = ''
_last_card_id = -1
vstatus.mk.set_messages([(center('BYE!'), False, 1.5)])
reset_idler(v, vstatus, 2)
return
......@@ -842,12 +844,17 @@ def handle_door_event(state, event, params, v, vstatus):
logging.warning('Leaving open door mode')
v.display("-YUM YUM!-")
_last_card_id = -1
def handle_mifare_event(state, event, params, v, vstatus):
global _last_card_id
card_id = params
# Translate card_id into uid.
if card_id == None:
if card_id == None or card_id == _last_card_id:
return
_last_card_id = card_id
try:
vstatus.cur_user = get_uid(card_id)
logging.info('Mapped card id to uid %s'%vstatus.cur_user)
......@@ -885,12 +892,15 @@ def handle_mifare_event(state, event, params, v, vstatus):
return
def handle_mifare_add_user_event(state, event, params, v, vstatus):
card_id = params
global _last_card_id
card_id = params
# Translate card_id into uid.
if card_id == None:
if card_id == None or card_id == _last_card_id:
return
_last_card_id = card_id
try:
if get_uid(card_id) != None:
vstatus.mk.set_messages(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment