mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 16:36:25 +02:00
Better handling of unknown UIDs
This commit is contained in:
parent
16a5f149b4
commit
703c214421
2 changed files with 8 additions and 2 deletions
|
@ -1,9 +1,12 @@
|
||||||
# auth_db_filename - sqlite filename of authorized UIDs, create with create_authenticator_db.py
|
# auth_db_filename - sqlite filename of authorized UIDs, create with create_authenticator_db.py
|
||||||
# lock_opened_secs - how long lock should be held open in seconds, default 5
|
# lock_opened_secs - how long lock should be held open in seconds, default 5
|
||||||
|
# unknown_uid_timeout_secs - how long to wait after scanning unknown UID -
|
||||||
|
# prevents too many messages
|
||||||
# log_file - logs read UIDs and when was lock opened, use - for stderr
|
# log_file - logs read UIDs and when was lock opened, use - for stderr
|
||||||
# log_level - minimum log level - one of debug, info, warn, error, fatal, default info
|
# log_level - minimum log level - one of debug, info, warn, error, fatal, default info
|
||||||
[brmdoor]
|
[brmdoor]
|
||||||
auth_db_filename = test_uids_db.sqlite
|
auth_db_filename = test_uids_db.sqlite
|
||||||
#lock_opened_secs = 5
|
#lock_opened_secs = 5
|
||||||
|
#unknown_uid_timeout_secs = 5
|
||||||
log_file = -
|
log_file = -
|
||||||
#log_level = info
|
#log_level = info
|
||||||
|
|
|
@ -24,6 +24,7 @@ class BrmdoorConfig(object):
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
"lock_opened_secs": "5",
|
"lock_opened_secs": "5",
|
||||||
|
"unknown_uid_timeout_secs": "5",
|
||||||
"log_level": "info"
|
"log_level": "info"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ class BrmdoorConfig(object):
|
||||||
|
|
||||||
self.authDbFilename = self.config.get("brmdoor", "auth_db_filename")
|
self.authDbFilename = self.config.get("brmdoor", "auth_db_filename")
|
||||||
self.lockOpenedSecs = self.config.getint("brmdoor", "lock_opened_secs")
|
self.lockOpenedSecs = self.config.getint("brmdoor", "lock_opened_secs")
|
||||||
|
self.unknownUidTimeoutSecs = self.config.getint("brmdoor", "unknown_uid_timeout_secs")
|
||||||
self.logFile = self.config.get("brmdoor", "log_file")
|
self.logFile = self.config.get("brmdoor", "log_file")
|
||||||
self.logLevel = self.convertLoglevel(self.config.get("brmdoor", "log_level"))
|
self.logLevel = self.convertLoglevel(self.config.get("brmdoor", "log_level"))
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ class NFCUnlocker(object):
|
||||||
"""Create worker reading UIDs from PN53x reader.
|
"""Create worker reading UIDs from PN53x reader.
|
||||||
"""
|
"""
|
||||||
self.authenticator = UidAuthenticator(config.authDbFilename)
|
self.authenticator = UidAuthenticator(config.authDbFilename)
|
||||||
|
self.unknownUidTimeoutSecs = config.unknownUidTimeoutSecs
|
||||||
self.lockOpenedSecs = config.lockOpenedSecs
|
self.lockOpenedSecs = config.lockOpenedSecs
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -99,8 +102,8 @@ class NFCUnlocker(object):
|
||||||
|
|
||||||
#no match
|
#no match
|
||||||
if record is None:
|
if record is None:
|
||||||
logging.info("Unknown UID")
|
logging.info("Unknown UID %s", uid_hex)
|
||||||
time.sleep(0.3)
|
time.sleep(self.unknownUidTimeoutSecs)
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.info("Unlocking for UID %s", record)
|
logging.info("Unlocking for UID %s", record)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue