Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NFC_HTM_READ EMULAR_TAGS Escribir_tag NFC_HTM_READ-WRITE
NfcAdapter.h@0:b805b487fbef, 2015-04-24 (annotated)
- Committer:
- mauroar211
- Date:
- Fri Apr 24 18:17:09 2015 +0000
- Revision:
- 0:b805b487fbef
- Child:
- 1:a549ef8b142a
LEER TAG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mauroar211 | 0:b805b487fbef | 1 | #ifndef NfcAdapter_h |
mauroar211 | 0:b805b487fbef | 2 | #define NfcAdapter_h |
mauroar211 | 0:b805b487fbef | 3 | |
mauroar211 | 0:b805b487fbef | 4 | #include <PN532Interface.h> |
mauroar211 | 0:b805b487fbef | 5 | #include <PN532.h> |
mauroar211 | 0:b805b487fbef | 6 | #include <NfcTag.h> |
mauroar211 | 0:b805b487fbef | 7 | #include <Ndef.h> |
mauroar211 | 0:b805b487fbef | 8 | |
mauroar211 | 0:b805b487fbef | 9 | // Drivers |
mauroar211 | 0:b805b487fbef | 10 | #include <MifareClassic.h> |
mauroar211 | 0:b805b487fbef | 11 | #include <MifareUltralight.h> |
mauroar211 | 0:b805b487fbef | 12 | |
mauroar211 | 0:b805b487fbef | 13 | #define TAG_TYPE_MIFARE_CLASSIC (0) |
mauroar211 | 0:b805b487fbef | 14 | #define TAG_TYPE_1 (1) |
mauroar211 | 0:b805b487fbef | 15 | #define TAG_TYPE_2 (2) |
mauroar211 | 0:b805b487fbef | 16 | #define TAG_TYPE_3 (3) |
mauroar211 | 0:b805b487fbef | 17 | #define TAG_TYPE_4 (4) |
mauroar211 | 0:b805b487fbef | 18 | #define TAG_TYPE_UNKNOWN (99) |
mauroar211 | 0:b805b487fbef | 19 | |
mauroar211 | 0:b805b487fbef | 20 | #define IRQ (2) |
mauroar211 | 0:b805b487fbef | 21 | #define RESET (3) // Not connected by default on the NFC Shield |
mauroar211 | 0:b805b487fbef | 22 | |
mauroar211 | 0:b805b487fbef | 23 | class NfcAdapter { |
mauroar211 | 0:b805b487fbef | 24 | public: |
mauroar211 | 0:b805b487fbef | 25 | NfcAdapter(PN532Interface &interface); |
mauroar211 | 0:b805b487fbef | 26 | |
mauroar211 | 0:b805b487fbef | 27 | ~NfcAdapter(void); |
mauroar211 | 0:b805b487fbef | 28 | void begin(void); |
mauroar211 | 0:b805b487fbef | 29 | bool tagPresent(); // tagAvailable |
mauroar211 | 0:b805b487fbef | 30 | NfcTag read(); |
mauroar211 | 0:b805b487fbef | 31 | bool write(NdefMessage& ndefMessage); |
mauroar211 | 0:b805b487fbef | 32 | // FUTURE bool share(NdefMessage& ndefMessage); |
mauroar211 | 0:b805b487fbef | 33 | // FUTURE bool unshare(); |
mauroar211 | 0:b805b487fbef | 34 | // FUTURE bool erase(); |
mauroar211 | 0:b805b487fbef | 35 | // FUTURE bool format(); |
mauroar211 | 0:b805b487fbef | 36 | private: |
mauroar211 | 0:b805b487fbef | 37 | PN532* shield; |
mauroar211 | 0:b805b487fbef | 38 | uint8_t uid[7]; // Buffer to store the returned UID |
mauroar211 | 0:b805b487fbef | 39 | unsigned int uidLength; // Length of the UID (4 or 7 uint8_ts depending on ISO14443A card type) |
mauroar211 | 0:b805b487fbef | 40 | unsigned int guessTagType(); |
mauroar211 | 0:b805b487fbef | 41 | }; |
mauroar211 | 0:b805b487fbef | 42 | |
mauroar211 | 0:b805b487fbef | 43 | #endif |