Utility library to read and write Ndef messages from/to a Type4 NFC tag

Dependents:   NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more

Fork of NDefLib by ST Expansion SW Team

NDEF NFC library

This library provides an abstract API to create NDEF formatted messages and records and to read/write them from/to a Type4 NFC Tag.

Implementations

At the moment, the NDEF API is implemented by X_NUCLEO_NFC01A1 and X_NUCLEO_NFC02A1 Dynamic NFC Tag libraries respectively driving the X-NUCLEO-NFC01A1 and X-NUCLEO-NFC02A1 boards.

Committer:
giovannivisentini
Date:
Tue Nov 24 14:33:06 2015 +0000
Revision:
1:a0eeb478a45a
Parent:
0:04b82ae7aa43
Child:
4:eaf6c49a86e4
implement tag reading

Who changed what in which revision?

UserRevisionLine numberNew contents of line
giovannivisentini 0:04b82ae7aa43 1 /*
giovannivisentini 0:04b82ae7aa43 2 * Message.h
giovannivisentini 0:04b82ae7aa43 3 *
giovannivisentini 0:04b82ae7aa43 4 * Created on: Nov 6, 2015
giovannivisentini 0:04b82ae7aa43 5 * Author: giovanni visentini
giovannivisentini 0:04b82ae7aa43 6 */
giovannivisentini 0:04b82ae7aa43 7
giovannivisentini 0:04b82ae7aa43 8 #ifndef NDEFLIB_MESSAGE_H_
giovannivisentini 0:04b82ae7aa43 9 #define NDEFLIB_MESSAGE_H_
giovannivisentini 0:04b82ae7aa43 10
giovannivisentini 0:04b82ae7aa43 11 #include <vector>
giovannivisentini 0:04b82ae7aa43 12
giovannivisentini 0:04b82ae7aa43 13 #include "Record.h"
giovannivisentini 0:04b82ae7aa43 14
giovannivisentini 0:04b82ae7aa43 15 namespace NDefLib {
giovannivisentini 0:04b82ae7aa43 16
giovannivisentini 0:04b82ae7aa43 17 class Message {
giovannivisentini 0:04b82ae7aa43 18 public:
giovannivisentini 0:04b82ae7aa43 19 Message(){}
giovannivisentini 0:04b82ae7aa43 20
giovannivisentini 0:04b82ae7aa43 21 void addRecord(Record *r){
giovannivisentini 0:04b82ae7aa43 22 mRecords.push_back(r);
giovannivisentini 0:04b82ae7aa43 23 }
giovannivisentini 0:04b82ae7aa43 24
giovannivisentini 1:a0eeb478a45a 25 void addRecords(const std::vector<Record*> &addList){
giovannivisentini 1:a0eeb478a45a 26 mRecords.insert(mRecords.end(),addList.begin(),addList.end());
giovannivisentini 1:a0eeb478a45a 27 }
giovannivisentini 1:a0eeb478a45a 28
giovannivisentini 1:a0eeb478a45a 29 Record* getRecord(const uint32_t index){
giovannivisentini 1:a0eeb478a45a 30 if(index>mRecords.size()){
giovannivisentini 1:a0eeb478a45a 31 return NULL;
giovannivisentini 1:a0eeb478a45a 32 }
giovannivisentini 1:a0eeb478a45a 33 return mRecords[index];
giovannivisentini 1:a0eeb478a45a 34 }
giovannivisentini 1:a0eeb478a45a 35
giovannivisentini 1:a0eeb478a45a 36 uint32_t getNRecords()const{
giovannivisentini 1:a0eeb478a45a 37 return mRecords.size();
giovannivisentini 1:a0eeb478a45a 38 }
giovannivisentini 1:a0eeb478a45a 39
giovannivisentini 0:04b82ae7aa43 40 uint16_t getByteLenght()const;
giovannivisentini 1:a0eeb478a45a 41 uint16_t write(uint8_t *buffer)const;
giovannivisentini 0:04b82ae7aa43 42
giovannivisentini 1:a0eeb478a45a 43 static void parseMessage(const uint8_t *const buffer,const uint8_t bufferLength,Message *mesage);
giovannivisentini 0:04b82ae7aa43 44
giovannivisentini 0:04b82ae7aa43 45 virtual ~Message(){}
giovannivisentini 0:04b82ae7aa43 46 private:
giovannivisentini 0:04b82ae7aa43 47 std::vector<Record*> mRecords;
giovannivisentini 0:04b82ae7aa43 48 };
giovannivisentini 0:04b82ae7aa43 49
giovannivisentini 0:04b82ae7aa43 50 } /* namespace NDefLib */
giovannivisentini 0:04b82ae7aa43 51
giovannivisentini 0:04b82ae7aa43 52 #endif /* NDEFLIB_MESSAGE_H_ */