more nfc
This commit is contained in:
parent
386cbc2c0a
commit
9a55dec5f2
5
main.py
5
main.py
@ -106,14 +106,17 @@ class CliInteraction(UserInteraction):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def read_nfc_tag():
|
def read_nfc_tag():
|
||||||
|
clf = None
|
||||||
try:
|
try:
|
||||||
clf = nfc.ContactlessFrontend('usb')
|
clf = nfc.ContactlessFrontend('usb')
|
||||||
tag = clf.connect(rdwr={'on-connect': lambda tag: False})
|
tag = clf.connect(rdwr={'on-connect': lambda tag: False})
|
||||||
clf.close()
|
|
||||||
return tag.identifier if tag else None
|
return tag.identifier if tag else None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("NFC read error:", e)
|
print("NFC read error:", e)
|
||||||
return None
|
return None
|
||||||
|
finally:
|
||||||
|
if clf:
|
||||||
|
clf.close()
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user