forked from don/NDEF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NdefRecord.h
60 lines (50 loc) · 1.43 KB
/
NdefRecord.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef NdefRecord_h
#define NdefRecord_h
#include <Due.h>
#include <Arduino.h>
#include <Ndef.h>
#define TNF_EMPTY 0x0
#define TNF_WELL_KNOWN 0x01
#define TNF_MIME_MEDIA 0x02
#define TNF_ABSOLUTE_URI 0x03
#define TNF_EXTERNAL_TYPE 0x04
#define TNF_UNKNOWN 0x05
#define TNF_UNCHANGED 0x06
#define TNF_RESERVED 0x07
class NdefRecord
{
public:
NdefRecord();
NdefRecord(const NdefRecord& rhs);
~NdefRecord();
NdefRecord& operator=(const NdefRecord& rhs);
int getEncodedSize();
void encode(byte *data, bool firstRecord, bool lastRecord);
unsigned int getTypeLength();
int getPayloadLength();
unsigned int getIdLength();
byte getTnf();
void getType(byte *type);
void getPayload(byte *payload);
void getId(byte *id);
// convenience methods
String getType();
String getId();
void setTnf(byte tnf);
void setType(const byte *type, const unsigned int numBytes);
void setPayload(const byte *payload, const int numBytes);
void setId(const byte *id, const unsigned int numBytes);
#ifdef NDEF_USE_SERIAL
void print();
#endif
private:
byte getTnfByte(bool firstRecord, bool lastRecord);
byte _tnf; // 3 bit
unsigned int _typeLength;
int _payloadLength;
unsigned int _idLength;
byte *_type;
byte *_payload;
byte *_id;
};
#endif