Generic library for working with PN532-like chips
Fork of PN532 by
Diff: NfcAdapter.cpp
- Revision:
- 5:51f820fbd18a
- Parent:
- 3:4189a10038e6
- Child:
- 9:85bfede025da
--- a/NfcAdapter.cpp Thu Nov 21 04:41:47 2013 +0000 +++ b/NfcAdapter.cpp Tue Oct 07 15:09:46 2014 +0000 @@ -34,7 +34,7 @@ uidLength = 0; // TODO is cast of uidLength OK? - success = shield->readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, (uint8_t*)&uidLength); + success = shield->readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, (uint8_t*)&uidLength,&ATQA,&SAK); // if (success) // { @@ -90,7 +90,7 @@ bool NfcAdapter::write(NdefMessage& ndefMessage) { bool success; - + uint8_t type = guessTagType(); if (uidLength == 4) { MifareClassic mifareClassic = MifareClassic(*shield); @@ -98,8 +98,10 @@ } else { - DMSG("Unsupported Tag"); - success = false; + DMSG("Ultralight Tag"); + MifareUltralight mifareUltralight = MifareUltralight(*shield); + success= mifareUltralight.write(ndefMessage, uid, uidLength); + //success = false; } return success; } @@ -116,13 +118,21 @@ // - ATQA 0x44 && SAK 0x8 - Mifare Classic // - ATQA 0x44 && SAK 0x0 - Mifare Ultralight NFC Forum Type 2 // - ATQA 0x344 && SAK 0x20 - NFC Forum Type 4 - - if (uidLength == 4) + DMSG("Guess type"); + DMSG("ATQA: 0x"); DMSG_HEX(ATQA); + DMSG("SAK: 0x"); DMSG_HEX(SAK); + /*if (uidLength == 4) { return TAG_TYPE_MIFARE_CLASSIC; } else { return TAG_TYPE_2; + }*/ + if(ATQA==0x4&&SAK==0x8){ + return TAG_TYPE_MIFARE_CLASSIC; + } + if(ATQA==0x44&&SAK==0x0){ + return TAG_TYPE_2; } }