PN532 customized
Fork of PN532 by
Diff: MifareClassic.cpp
- Revision:
- 7:a26fa6ef10eb
- Parent:
- 3:4189a10038e6
--- a/MifareClassic.cpp Tue Mar 25 16:48:10 2014 +0000 +++ b/MifareClassic.cpp Tue Feb 09 16:16:11 2016 +0000 @@ -6,10 +6,30 @@ #define SHORT_TLV_SIZE 2 #define MIFARE_CLASSIC ("Mifare Classic") +#define TAG_TYPE_MIFARE_MINI (0) +#define TAG_TYPE_MIFARE_1K (1) +#define TAG_TYPE_MIFARE_4K (2) +#define TAG_TYPE_MIFARE_UL (3) +#define TAG_TYPE_MIFARE_PLUS_2K (4) +#define TAG_TYPE_MIFARE_PLUS_4K (5) +#define TAG_TYPE_14443 (6) -MifareClassic::MifareClassic(PN532& nfcShield) + +MifareClassic::MifareClassic(PN532& nfcShield, uint8_t tag_type) { _nfcShield = &nfcShield; + if(tag_type == TAG_TYPE_MIFARE_MINI) + type = "Mifare Classic Mini"; + else if(tag_type == TAG_TYPE_MIFARE_1K) + type = "Mifare Classic 1K"; + else if(tag_type == TAG_TYPE_MIFARE_4K) + type = "Mifare Classic 4K"; + else if(tag_type == TAG_TYPE_MIFARE_PLUS_2K) + type = "Mifare plus 2K"; + else if(tag_type == TAG_TYPE_MIFARE_PLUS_4K) + type = "Mifare plus 4K"; + else + type = "Unknown"; } MifareClassic::~MifareClassic() @@ -39,14 +59,14 @@ { DMSG("Error. Failed read block "); DMSG_INT(currentBlock); - return NfcTag(uid, uidLength, MIFARE_CLASSIC); + return NfcTag(uid, uidLength, type); } } else { DMSG("Tag is not NDEF formatted."); // TODO set tag.isFormatted = false - return NfcTag(uid, uidLength, MIFARE_CLASSIC); + return NfcTag(uid, uidLength, type); } // this should be nested in the message length loop @@ -107,7 +127,7 @@ } } - return NfcTag(uid, uidLength, MIFARE_CLASSIC, &buffer[messageStartIndex], messageLength); + return NfcTag(uid, uidLength, type, &buffer[messageStartIndex], messageLength); } int MifareClassic::getBufferSize(int messageLength)