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
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@5:f2b7efcc5b6e, 2015-12-01 (annotated)
- Committer:
- giovannivisentini
- Date:
- Tue Dec 01 15:59:55 2015 +0000
- Revision:
- 5:f2b7efcc5b6e
- Parent:
- 4:eaf6c49a86e4
- Child:
- 6:739e3211749d
add explicit to the constuctor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
giovannivisentini | 0:04b82ae7aa43 | 1 | /* |
giovannivisentini | 0:04b82ae7aa43 | 2 | * RecordAAR.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_RECORDTYPE_RECORDAAR_H_ |
giovannivisentini | 0:04b82ae7aa43 | 9 | #define NDEFLIB_RECORDTYPE_RECORDAAR_H_ |
giovannivisentini | 0:04b82ae7aa43 | 10 | |
giovannivisentini | 0:04b82ae7aa43 | 11 | #include <string> |
giovannivisentini | 0:04b82ae7aa43 | 12 | |
giovannivisentini | 0:04b82ae7aa43 | 13 | #include "NDefLib/Record.h" |
giovannivisentini | 4:eaf6c49a86e4 | 14 | |
giovannivisentini | 0:04b82ae7aa43 | 15 | namespace NDefLib { |
giovannivisentini | 0:04b82ae7aa43 | 16 | |
giovannivisentini | 4:eaf6c49a86e4 | 17 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 18 | * create a record that can start an application in an Android mobile |
giovannivisentini | 4:eaf6c49a86e4 | 19 | */ |
giovannivisentini | 0:04b82ae7aa43 | 20 | class RecordAAR: public Record { |
giovannivisentini | 0:04b82ae7aa43 | 21 | public: |
giovannivisentini | 4:eaf6c49a86e4 | 22 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 23 | * create an RecordAAR reading the data from the buffer |
giovannivisentini | 4:eaf6c49a86e4 | 24 | * @param header record header already read |
giovannivisentini | 4:eaf6c49a86e4 | 25 | * @param buffer buffer where read the data |
giovannivisentini | 4:eaf6c49a86e4 | 26 | * @return an object of type recordAAR or NULL |
giovannivisentini | 4:eaf6c49a86e4 | 27 | * @par free the pointer return by this function |
giovannivisentini | 4:eaf6c49a86e4 | 28 | */ |
giovannivisentini | 4:eaf6c49a86e4 | 29 | static RecordAAR* parse(const RecordHeader &header, |
giovannivisentini | 4:eaf6c49a86e4 | 30 | const uint8_t * const buffer); |
giovannivisentini | 1:a0eeb478a45a | 31 | |
giovannivisentini | 4:eaf6c49a86e4 | 32 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 33 | * build a new record |
giovannivisentini | 4:eaf6c49a86e4 | 34 | * @param packageName package of the application to start |
giovannivisentini | 4:eaf6c49a86e4 | 35 | */ |
giovannivisentini | 5:f2b7efcc5b6e | 36 | explicit RecordAAR(const std::string &packageName); |
giovannivisentini | 1:a0eeb478a45a | 37 | |
giovannivisentini | 0:04b82ae7aa43 | 38 | |
giovannivisentini | 0:04b82ae7aa43 | 39 | virtual uint16_t write(uint8_t *buffer); |
giovannivisentini | 1:a0eeb478a45a | 40 | |
giovannivisentini | 4:eaf6c49a86e4 | 41 | virtual RecordType_t getType() const { |
giovannivisentini | 1:a0eeb478a45a | 42 | return TYPE_AAR; |
giovannivisentini | 4:eaf6c49a86e4 | 43 | } //getType |
giovannivisentini | 1:a0eeb478a45a | 44 | |
giovannivisentini | 4:eaf6c49a86e4 | 45 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 46 | * @return get the package inside this record |
giovannivisentini | 4:eaf6c49a86e4 | 47 | */ |
giovannivisentini | 4:eaf6c49a86e4 | 48 | const std::string& getPackage() const { |
giovannivisentini | 1:a0eeb478a45a | 49 | return mPackageName; |
giovannivisentini | 1:a0eeb478a45a | 50 | } |
giovannivisentini | 1:a0eeb478a45a | 51 | |
giovannivisentini | 4:eaf6c49a86e4 | 52 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 53 | * change the package name of this record |
giovannivisentini | 4:eaf6c49a86e4 | 54 | * @param package |
giovannivisentini | 4:eaf6c49a86e4 | 55 | */ |
giovannivisentini | 4:eaf6c49a86e4 | 56 | void setPackage(const std::string& package){ |
giovannivisentini | 4:eaf6c49a86e4 | 57 | mPackageName=package; |
giovannivisentini | 4:eaf6c49a86e4 | 58 | mRecordHeader.setPlayloadLength(mPackageName.size()); |
giovannivisentini | 4:eaf6c49a86e4 | 59 | } |
giovannivisentini | 4:eaf6c49a86e4 | 60 | |
giovannivisentini | 4:eaf6c49a86e4 | 61 | virtual ~RecordAAR() { }; |
giovannivisentini | 0:04b82ae7aa43 | 62 | |
giovannivisentini | 0:04b82ae7aa43 | 63 | private: |
giovannivisentini | 4:eaf6c49a86e4 | 64 | std::string mPackageName; |
giovannivisentini | 0:04b82ae7aa43 | 65 | |
giovannivisentini | 4:eaf6c49a86e4 | 66 | /** |
giovannivisentini | 4:eaf6c49a86e4 | 67 | * string to use as record type for this record |
giovannivisentini | 4:eaf6c49a86e4 | 68 | */ |
giovannivisentini | 1:a0eeb478a45a | 69 | static const char sRecordType[]; |
giovannivisentini | 0:04b82ae7aa43 | 70 | }; |
giovannivisentini | 0:04b82ae7aa43 | 71 | |
giovannivisentini | 0:04b82ae7aa43 | 72 | } /* namespace NDefLib */ |
giovannivisentini | 0:04b82ae7aa43 | 73 | |
giovannivisentini | 0:04b82ae7aa43 | 74 | #endif /* NDEFLIB_RECORDTYPE_RECORDAAR_H_ */ |