From f889497777c5a0040ea83b7efe728703a19ac696 Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Sun, 4 Jul 2021 20:28:16 +0200 Subject: [PATCH] Try to fix single "no card detected"-events while rfid-tag is applied --- src/RfidPn5180.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/RfidPn5180.cpp b/src/RfidPn5180.cpp index d638b8a..1e9fe84 100644 --- a/src/RfidPn5180.cpp +++ b/src/RfidPn5180.cpp @@ -50,6 +50,8 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; void Rfid_Read(void) { static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST); static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST); + static uint32_t lastTimeDetected14443 = 0; + static uint32_t lastTimeDetected15693 = 0; static uint8_t stateMachine = RFID_PN5180_STATE_INIT; static byte cardId[cardIdSize], lastCardId[cardIdSize]; uint8_t uid[10]; @@ -68,7 +70,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; Serial.println(firmwareVersion[0]); // activate RF field - delay(4); + delay(4u); Log_Println((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG); // 1. check for an ISO-14443 card @@ -80,11 +82,16 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; if (nfc14443.readCardSerial(uid) >= 4u) { cardReceived = true; stateMachine = RFID_PN5180_NFC14443_STATE_ACTIVE; + lastTimeDetected14443 = millis(); } else { // Reset to dummy-value if no card is there // Necessary to differentiate between "card is still applied" and "card is re-applied again after removal" - for (uint8_t i=0; i= 300)) { + lastTimeDetected14443 = 0; + for (uint8_t i=0; i= 300)) { + lastTimeDetected15693 = 0; + for (uint8_t i=0; i