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.
Diff: NDefNfcTag.h
- Revision:
- 12:ed4d9b8d1410
- Parent:
- 11:eaf42739791e
- Child:
- 14:ba0c186ae6d6
diff -r eaf42739791e -r ed4d9b8d1410 NDefNfcTag.h --- a/NDefNfcTag.h Mon Jan 11 13:04:33 2016 +0000 +++ b/NDefNfcTag.h Thu Jan 14 07:54:44 2016 +0000 @@ -43,7 +43,7 @@ namespace NDefLib { /** - * Abstract class used for write/read NDef message in an nfc tag + * Abstract class used to write/read NDef messages to/from a nfc tag */ class NDefNfcTag { public: @@ -51,9 +51,9 @@ NDefNfcTag():mSessionIsOpen(false){} /** - * open the communication with the nfc tag - * \par when override this method call this implementation as last action for set the session opened - * @param force force to open a communication + * Open the communication session with the nfc tag. + * @par This method should be called at the end of an overriding implementation, just before returning. + * @param force Force to open a communication. * @return true if success */ virtual bool openSession(bool force = false){ @@ -62,8 +62,8 @@ } /** - * close the communication with the nfc tag - * \par when override this method call this implementation as last action for set the session closed + * Close the communication with the nfc tag. + * @par This method should be called at the end of an overriding implementation, just before returning. * @return true if success */ virtual bool closeSession(){ @@ -72,8 +72,9 @@ } /** - * write a message in the nfc tag, this call will delete the previous message - * @param msg message to write + * Write a message in the nfc tag. + * @par This call will delete the previous message. + * @param msg Message to write. * @return true if success */ bool write(const Message &msg) { @@ -82,7 +83,7 @@ const uint16_t length = msg.getByteLength(); uint8_t *buffer = new uint8_t[length]; - if(buffer==NULL) //impossible allocate the buffer for write the message + if(buffer==NULL) //impossible to allocate the buffer return false; msg.write(buffer); bool retValue = writeByte(buffer, length); @@ -91,9 +92,8 @@ } /** - * read a message from the tag - * @param[in,out] msg message object where we will add the record read by the - * tag + * Read a message from the tag. + * @param[in,out] msg Message object the read records are added to. * @return true if success */ bool read(Message *msg) { @@ -108,7 +108,7 @@ if(buffer==NULL) return false; - //read all the message content + //read all the message contents bool retValue = readByte(2, length, buffer); if (retValue) { Message::parseMessage(buffer, length, msg); @@ -120,8 +120,8 @@ virtual ~NDefNfcTag() {} /** - * true if we have a communication open with the nfc tag - * @return + * Returns true if a communication with the nfc tag is open. + * @return true if a communication with the nfc tag is open */ bool isSessionOpen(){ return mSessionIsOpen; @@ -131,32 +131,33 @@ protected: /** - * write a sequence of byte in the NDEF file - * @param buffer buffer to write - * @param length number of byte to write - * @param offset offset where start to write + * Write a sequence of bytes to the NDEF file. + * @param buffer Buffer to write. + * @param length Number of bytes to write. + * @param offset Write offset in bytes. * @return true if success */ virtual bool writeByte(const uint8_t *buffer, uint16_t length, uint16_t offset=0)=0; /** - * read a sequence of byte from the NDEF file - * @param byteOffset offset were start read - * @param byteLength number of byte to read - * @param[out] buffer buffer where store the data read + * Read a sequence of bytes from the NDEF file. + * @param byteOffset Read offsetin bytes. + * @param byteLength Number of bytes to read. + * @param[out] buffer Buffer to store the read data into. * @return true if success */ virtual bool readByte(const uint16_t byteOffset, const uint16_t byteLength, uint8_t *buffer)=0; private: + /** - * variable to set when we open/close a communication channel with the tag + * Provides the status of a communication channel with the tag. */ bool mSessionIsOpen; /** - * read the NDEF message length + * Read the NDEF message length. * @return NDEF message length */ uint16_t getMessageLength() {