NFC library using PN532 to read/write NDEF Messages to NFC tags

Dependents:   Seeed_NFC_Shield_write Nucleo_test_nfc

Fork of PN532 by Yihui Xiong

NdefMessage.h

Committer:
screamer
Date:
2014-03-25
Revision:
6:26c1b3b6c192
Parent:
3:4189a10038e6

File content as of revision 6:26c1b3b6c192:

#ifndef NdefMessage_h
#define NdefMessage_h

#include <Ndef.h>
#include <NdefRecord.h>

#define MAX_NDEF_RECORDS 4

class NdefMessage
{
    public:
        NdefMessage(void);
        NdefMessage(const uint8_t *data, const int numuint8_ts);
        NdefMessage(const NdefMessage& rhs);
        ~NdefMessage();
        NdefMessage& operator=(const NdefMessage& rhs);

        int getEncodedSize(); // need so we can pass array to encode
        void encode(uint8_t *data);

        bool addRecord(NdefRecord& record);
        void addMimeMediaRecord(string mimeType, string payload);
        void addMimeMediaRecord(string mimeType, uint8_t *payload, int payloadLength);
        void addTextRecord(string text);
        void addTextRecord(string text, string encoding);
        void addUriRecord(string uri);
        void addEmptyRecord();

        unsigned int getRecordCount();
        NdefRecord getRecord(int index);
        NdefRecord operator[](int index);

        void print();
    private:
        NdefRecord _records[MAX_NDEF_RECORDS];
        unsigned int _recordCount;
};

#endif