Browse Source

Fixing recognition of ISO15693 via PN5180

master
Torsten Stauder 4 years ago
parent
commit
ec458521cd
  1. 14
      src/RfidPn5180.cpp
  2. 2
      src/main.cpp

14
src/RfidPn5180.cpp

@ -83,6 +83,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
cardReceived = true; cardReceived = true;
stateMachine = RFID_PN5180_NFC14443_STATE_ACTIVE; stateMachine = RFID_PN5180_NFC14443_STATE_ACTIVE;
lastTimeDetected14443 = millis(); lastTimeDetected14443 = millis();
//Serial.println("14443");
} else { } else {
// Reset to dummy-value if no card is there // 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" // 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; cardReceived = true;
stateMachine = RFID_PN5180_NFC15693_STATE_ACTIVE; stateMachine = RFID_PN5180_NFC15693_STATE_ACTIVE;
lastTimeDetected15693 = millis(); lastTimeDetected15693 = millis();
//Serial.println("15693");
} else { } else {
// lastTimeDetected15693 is used to prevent "new card detection with old card" with single events where no card was detected // lastTimeDetected15693 is used to prevent "new card detection with old card" with single events where no card was detected
if (!lastTimeDetected15693 || (millis() - lastTimeDetected15693 >= 400)) { if (!lastTimeDetected15693 || (millis() - lastTimeDetected15693 >= 400)) {
@ -138,13 +140,21 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
// check for different card id // check for different card id
if (memcmp((const void *)cardId, (const void *)lastCardId, sizeof(cardId)) == 0) { if (memcmp((const void *)cardId, (const void *)lastCardId, sizeof(cardId)) == 0) {
// reset state machine // 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); memcpy(lastCardId, cardId, cardIdSize);
Log_Print((char *) FPSTR(rfidTagDetected), LOGLEVEL_NOTICE); 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++) { for (uint8_t i = 0u; i < cardIdSize; i++) {
snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n"); snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n");
Log_Print(Log_Buffer, LOGLEVEL_NOTICE); Log_Print(Log_Buffer, LOGLEVEL_NOTICE);

2
src/main.cpp

@ -184,7 +184,7 @@ void setup() {
Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |")); Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |"));
Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ ")); Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ "));
Serial.println(F(" Rfid-controlled musicplayer\n")); 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 // print wake-up reason
printWakeUpReason(); printWakeUpReason();

Loading…
Cancel
Save