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.

RecordType/RecordAAR.h

Committer:
giovannivisentini
Date:
2015-12-01
Revision:
4:eaf6c49a86e4
Parent:
1:a0eeb478a45a
Child:
5:f2b7efcc5b6e

File content as of revision 4:eaf6c49a86e4:

/*
 * RecordAAR.h
 *
 *  Created on: Nov 6, 2015
 *      Author: giovanni visentini
 */

#ifndef NDEFLIB_RECORDTYPE_RECORDAAR_H_
#define NDEFLIB_RECORDTYPE_RECORDAAR_H_

#include <string>

#include "NDefLib/Record.h"

namespace NDefLib {

/**
 * create a record that can start an application in an Android mobile
 */
class RecordAAR: public Record {
public:
	/**
	 * create an RecordAAR reading the data from the buffer
 	 * @param header record header already read
	 * @param buffer buffer where read the data
	 * @return an object of type recordAAR or NULL
	 * @par free the pointer return by this function
	 */
	static RecordAAR* parse(const RecordHeader &header,
			const uint8_t * const buffer);

	/**
	 * build a new record
	 * @param packageName package of the application to start
	 */
	RecordAAR(const std::string &packageName);


	virtual uint16_t write(uint8_t *buffer);

	virtual RecordType_t getType() const {
		return TYPE_AAR;
	} //getType

	/**
	 * @return get the package inside this record
	 */
	const std::string& getPackage() const {
		return mPackageName;
	}

	/**
	 * change the package name of this record
	 * @param package
	 */
	void setPackage(const std::string& package){
		mPackageName=package;
		mRecordHeader.setPlayloadLength(mPackageName.size());
	}

	virtual ~RecordAAR() {	};

private:
	std::string mPackageName;

	/**
	 * string to use as record type for this record
	 */
	static const char sRecordType[];
};

} /* namespace NDefLib */

#endif /* NDEFLIB_RECORDTYPE_RECORDAAR_H_ */