-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathntagadapter.h
37 lines (33 loc) · 1.08 KB
/
ntagadapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef NTAGADAPTER_H
#define NTAGADAPTER_H
#include "ntag.h"
#include "NfcTag.h"
class NtagAdapter
{
public:
virtual bool begin();
virtual bool write(NdefMessage& message, unsigned int uiTimeout=0)=0;
virtual NfcTag read(unsigned int uiTimeOut=0)=0;
boolean readerPresent(unsigned long timeout=0);
bool rfBusy();
// erase tag by writing an empty NDEF record
boolean erase();
// format a tag as NDEF
boolean format();
// reset tag back to factory state
boolean clean();
bool getUid(byte *uidin, unsigned int uidLength);
byte getUidLength();
protected:
static const byte NTAG_PAGE_SIZE=4;
static const byte NTAG_BLOCK_SIZE=16;
static const byte NTAG_DATA_START_BLOCK=1;
static const byte MESSAGE_TYPE_NDEF=3;//TLV Block type
Ntag* _ntag;
bool waitUntilRfDone(unsigned int uiTimeOut);
static const byte UID_LENGTH=7;
bool decodeTlv(byte *data, int &messageLength, int &messageStartIndex);
int getNdefStartIndex(byte *data);
byte uid[UID_LENGTH]; // Buffer to store the returned UID
};
#endif // NTAGADAPTER_H