From 40ddf07c002412a943806d03a056f189e2ca646a Mon Sep 17 00:00:00 2001 From: Lech Date: Wed, 28 Mar 2018 22:38:45 +0200 Subject: [PATCH] NfcAuthenticator: Reset PCD every read Sometimes PCD driver would hang, causing inability to read NFC keys. This is to fix the issue, increasing loop time only slightly. --- NfcAuthenticator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NfcAuthenticator.cpp b/NfcAuthenticator.cpp index f4b7374..69b6aff 100644 --- a/NfcAuthenticator.cpp +++ b/NfcAuthenticator.cpp @@ -8,7 +8,6 @@ NfcAuthenticator::NfcAuthenticator(int nfcSlaveSelectPin, int nfcResetPin, const logger(logger) { SPI.begin(); - rfid.PCD_Init(); } NfcAuthenticator::~NfcAuthenticator() @@ -29,6 +28,8 @@ Key NfcAuthenticator::getKey() bool NfcAuthenticator::initializeCard() { + rfid.PCD_Init(); + if (!rfid.PICC_IsNewCardPresent()) return false;