From ec458521cd5aaefca5f40109c86ab78d61aae286 Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Fri, 9 Jul 2021 00:23:18 +0200 Subject: [PATCH] Fixing recognition of ISO15693 via PN5180 --- src/RfidPn5180.cpp | 14 ++++++++++++-- src/main.cpp | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/RfidPn5180.cpp b/src/RfidPn5180.cpp index 4264155..bb9a96b 100644 --- a/src/RfidPn5180.cpp +++ b/src/RfidPn5180.cpp @@ -83,6 +83,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; cardReceived = true; stateMachine = RFID_PN5180_NFC14443_STATE_ACTIVE; lastTimeDetected14443 = millis(); + //Serial.println("14443"); } 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" @@ -118,6 +119,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; cardReceived = true; stateMachine = RFID_PN5180_NFC15693_STATE_ACTIVE; lastTimeDetected15693 = millis(); + //Serial.println("15693"); } else { // lastTimeDetected15693 is used to prevent "new card detection with old card" with single events where no card was detected if (!lastTimeDetected15693 || (millis() - lastTimeDetected15693 >= 400)) { @@ -138,13 +140,21 @@ extern unsigned long Rfid_LastRfidCheckTimestamp; // check for different card id if (memcmp((const void *)cardId, (const void *)lastCardId, sizeof(cardId)) == 0) { // reset state machine - stateMachine = RFID_PN5180_NFC14443_STATE_RESET; - return; + if (RFID_PN5180_NFC14443_STATE_ACTIVE == stateMachine) { + stateMachine = RFID_PN5180_NFC14443_STATE_RESET; + return; + } else if (RFID_PN5180_NFC15693_STATE_ACTIVE == stateMachine) { + stateMachine = RFID_PN5180_NFC15693_STATE_RESET; + return; + } } memcpy(lastCardId, cardId, cardIdSize); Log_Print((char *) FPSTR(rfidTagDetected), LOGLEVEL_NOTICE); + snprintf(Log_Buffer, Log_BufferLength, "(%s) ID: ", (RFID_PN5180_NFC14443_STATE_ACTIVE == stateMachine) ? "ISO-14443" : "ISO-15693"); + Log_Print(Log_Buffer, LOGLEVEL_NOTICE); + for (uint8_t i = 0u; i < cardIdSize; i++) { snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n"); Log_Print(Log_Buffer, LOGLEVEL_NOTICE); diff --git a/src/main.cpp b/src/main.cpp index af46b84..fbe343f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,7 @@ void setup() { Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |")); Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ ")); Serial.println(F(" Rfid-controlled musicplayer\n")); - Serial.println(F(" Rev 20210708-3\n")); + Serial.println(F(" Rev 20210709-1\n")); // print wake-up reason printWakeUpReason();