From 33c571c78669c60bf4be3cff2f02278510497b13 Mon Sep 17 00:00:00 2001 From: Mitchell Pomery Date: Mon, 2 Mar 2015 21:52:31 +0800 Subject: [PATCH] MIFARE Reader only triggers once unless a new card is used --- VendServer/VendServer.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/VendServer/VendServer.py b/VendServer/VendServer.py index ef74c0d..8fbf11e 100755 --- a/VendServer/VendServer.py +++ b/VendServer/VendServer.py @@ -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( -- 2.20.1