From 386cbc2c0a18d4cb3bf99aef650c52675aee5732 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Thu, 9 May 2024 21:47:06 -0400 Subject: [PATCH] try nfc --- install.sh | 2 +- main.py | 20 +++++++++++--------- startup.sh | 1 - 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index edb41b0..a6de1d3 100644 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ sudo apt-get install python3-psycopg2 -y sudo apt-get install python3-fido2 -y sudo apt-get install python3-nfcpy -y sudo apt-get install screen -y -#test + sudo apt-get update sudo apt-get upgrade -y diff --git a/main.py b/main.py index 44b9ca5..e336a54 100644 --- a/main.py +++ b/main.py @@ -105,26 +105,28 @@ class CliInteraction(UserInteraction): print("User Verification required.") return True -try: - clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection - print("NFC reader initialized.") -except Exception as e: - print("Failed to initialize NFC reader:", e) - - +def read_nfc_tag(): + try: + clf = nfc.ContactlessFrontend('usb') + tag = clf.connect(rdwr={'on-connect': lambda tag: False}) + clf.close() + return tag.identifier if tag else None + except Exception as e: + print("NFC read error:", e) + return None while True: if gpie: GPIO.output(door, GPIO.LOW) - # GPIO.output(14, GPIO.LOW) + print("Waiting for device...") badCredentials = False if gpie: GPIO.output(redLed, GPIO.HIGH) while True: try: - # GPIO.output(14, GPIO.LOW) + nfc_tag = read_nfc_tag() dev = next(CtapHidDevice.list_devices(), None) if dev: diff --git a/startup.sh b/startup.sh index ccc63fe..3980bca 100644 --- a/startup.sh +++ b/startup.sh @@ -2,7 +2,6 @@ sudo cp /user/CNSA/CNSA-276-FP/config.ini /config.bak sudo rm -R /user/CNSA/CNSA-276-FP -#test2 # Function to check internet connectivity check_internet_connection() {