some additional fixes
Fork of PN532 by
NfcAdapter.h@10:5e24ab94fcc4, 2016-06-02 (annotated)
- Committer:
- vilesovds
- Date:
- Thu Jun 02 16:23:37 2016 +0000
- Revision:
- 10:5e24ab94fcc4
- Parent:
- 5:51f820fbd18a
fixed NfcTag::getUid
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 3:4189a10038e6 | 1 | #ifndef NfcAdapter_h |
yihui | 3:4189a10038e6 | 2 | #define NfcAdapter_h |
yihui | 3:4189a10038e6 | 3 | |
yihui | 3:4189a10038e6 | 4 | #include <PN532Interface.h> |
yihui | 3:4189a10038e6 | 5 | #include <PN532.h> |
yihui | 3:4189a10038e6 | 6 | #include <NfcTag.h> |
yihui | 3:4189a10038e6 | 7 | #include <Ndef.h> |
yihui | 3:4189a10038e6 | 8 | |
yihui | 3:4189a10038e6 | 9 | // Drivers |
yihui | 3:4189a10038e6 | 10 | #include <MifareClassic.h> |
yihui | 3:4189a10038e6 | 11 | #include <MifareUltralight.h> |
yihui | 3:4189a10038e6 | 12 | |
yihui | 3:4189a10038e6 | 13 | #define TAG_TYPE_MIFARE_CLASSIC (0) |
yihui | 3:4189a10038e6 | 14 | #define TAG_TYPE_1 (1) |
yihui | 3:4189a10038e6 | 15 | #define TAG_TYPE_2 (2) |
yihui | 3:4189a10038e6 | 16 | #define TAG_TYPE_3 (3) |
yihui | 3:4189a10038e6 | 17 | #define TAG_TYPE_4 (4) |
yihui | 3:4189a10038e6 | 18 | #define TAG_TYPE_UNKNOWN (99) |
yihui | 3:4189a10038e6 | 19 | |
yihui | 3:4189a10038e6 | 20 | #define IRQ (2) |
yihui | 3:4189a10038e6 | 21 | #define RESET (3) // Not connected by default on the NFC Shield |
yihui | 3:4189a10038e6 | 22 | |
yihui | 3:4189a10038e6 | 23 | class NfcAdapter { |
yihui | 3:4189a10038e6 | 24 | public: |
yihui | 3:4189a10038e6 | 25 | NfcAdapter(PN532Interface &interface); |
yihui | 3:4189a10038e6 | 26 | |
yihui | 3:4189a10038e6 | 27 | ~NfcAdapter(void); |
yihui | 3:4189a10038e6 | 28 | void begin(void); |
yihui | 3:4189a10038e6 | 29 | bool tagPresent(); // tagAvailable |
yihui | 3:4189a10038e6 | 30 | NfcTag read(); |
yihui | 3:4189a10038e6 | 31 | bool write(NdefMessage& ndefMessage); |
yihui | 3:4189a10038e6 | 32 | // FUTURE bool share(NdefMessage& ndefMessage); |
yihui | 3:4189a10038e6 | 33 | // FUTURE bool unshare(); |
yihui | 3:4189a10038e6 | 34 | // FUTURE bool erase(); |
yihui | 3:4189a10038e6 | 35 | // FUTURE bool format(); |
yihui | 3:4189a10038e6 | 36 | private: |
yihui | 3:4189a10038e6 | 37 | PN532* shield; |
yihui | 3:4189a10038e6 | 38 | uint8_t uid[7]; // Buffer to store the returned UID |
yihui | 3:4189a10038e6 | 39 | unsigned int uidLength; // Length of the UID (4 or 7 uint8_ts depending on ISO14443A card type) |
yihui | 3:4189a10038e6 | 40 | unsigned int guessTagType(); |
icefeet | 5:51f820fbd18a | 41 | uint16_t ATQA; |
icefeet | 5:51f820fbd18a | 42 | uint8_t SAK; |
yihui | 3:4189a10038e6 | 43 | }; |
yihui | 3:4189a10038e6 | 44 | |
yihui | 3:4189a10038e6 | 45 | #endif |