forked from don/NDEF
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNdefMessage.h
55 lines (44 loc) · 1.82 KB
/
NdefMessage.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
#ifndef NdefMessage_h
#define NdefMessage_h
#include <Ndef.h>
#include <NdefRecord.h>
#define MAX_NDEF_RECORDS 4
class NdefMessage
{
public:
NdefMessage(void);
NdefMessage(const byte *data, const int numBytes);
NdefMessage(const NdefMessage& rhs);
~NdefMessage();
NdefMessage& operator=(const NdefMessage& rhs);
int getEncodedSize(); // need so we can pass array to encode
void encode(byte *data);
boolean addRecord(NdefRecord& record);
void addMimeMediaRecord(const char *mimeType, const char *payload);
void addMimeMediaRecord(const char *mimeType, const byte *payload, int payloadLength);
void addTextRecord(const char *text);
void addTextRecord(const char *text, const char *encoding);
void addUriRecord(const char *uri);
void addExternalRecord(const char *type, const char *payload);
void addExternalRecord(const char *type, const byte *payload, int payloadLength);
/**
* Creates an Android Application Record (AAR) http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar
* Use an AAR record to cause a P2P message pushed to your Android phone to launch your app even if it's not running.
* Note, Android version must be >= 4.0 and your app must have the package you pass to this method
*
* @param packageName example: "com.acme.myapp"
*/
void addAndroidApplicationRecord(const char *packageName);
void addUnknownRecord(const byte *payload, int payloadLength);
void addEmptyRecord();
unsigned int getRecordCount();
NdefRecord getRecord(int index);
NdefRecord operator[](int index);
#ifdef NDEF_USE_SERIAL
void print();
#endif
private:
NdefRecord _records[MAX_NDEF_RECORDS];
unsigned int _recordCount;
};
#endif