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.

Revision:
12:ed4d9b8d1410
Parent:
9:689c1f56f359
Child:
13:dbf3a61d70b3
--- a/RecordType/RecordURI.h	Mon Jan 11 13:04:33 2016 +0000
+++ b/RecordType/RecordURI.h	Thu Jan 14 07:54:44 2016 +0000
@@ -4,7 +4,7 @@
  * @author  ST / Central Labs
  * @version V1.0.0
  * @date    6 Nov 2015
- * @brief   {@link Record} that contains a Uri address
+ * @brief   {@link Record} that contains an URI address
  ******************************************************************************
  * @attention
  *
@@ -44,25 +44,25 @@
 namespace NDefLib {
 
 /**
- * {@link Record} that contains a Uri address
+ * {@link Record} that contains an URI address.
  */
 class RecordURI: public Record {
 
 public:
 
 	/**
-	 * load a record uri from a buffer
-	 * @param header record header already read
-	 * @param buffer buffer where read the tag playload
+	 * Load a record URI from a buffer.
+	 * @param header Record header.
+	 * @param buffer Buffer to read the tag playload from.
 	 * @return record or NULL if it was not possible build it
- 	 * @par free the pointer return by this function
+	 * @par User is in charge of freeing the pointer returned by this function.
 	 */
 	static RecordURI* parse(const RecordHeader &header,
 			const uint8_t *buffer);
 
 	/**
-	 * if you want encode an know uri you can use this define for
-	 * avoid to encode the uri type as string
+	 * If you want encode an know URI you can use this define to
+	 * avoid to encode the URI type as string
 	 */
 	typedef enum {
 		UNKNOWN = 0X00,     //!< UNKNOWN
@@ -104,20 +104,20 @@
 	} knowUriId_t;
 
 	/**
-	 * build RecordUri with know uri type
-	 * @param uriId uri type
-	 * @param uriContent uri content
-	 * @par we will remove from the content the prefix encoded as part of the know uri
-	 * @par the string is copyed inside the class
+	 * Build RecordUri with a defined URI type.
+	 * @param URIId URI type.
+	 * @param URIContent URI content.
+	 * @par The URI prefix is removed.
+	 * @par The string is copied inside the class.
 	 */
-	explicit RecordURI(knowUriId_t uriId, const std::string &uriContent="");
+	explicit RecordURI(knowUriId_t URIId, const std::string &URIContent="");
 
 	/**
-	 * build an unknown uri type
-	 * @param uriType string with the uri type
-	 * @param uriContent uri content
+	 * Build a custom URI type.
+	 * @param URIType string with the URI type.
+	 * @param URIContent URI content.
 	 */
-	explicit RecordURI(const std::string &uriType, const std::string &uriContent="");
+	explicit RecordURI(const std::string &URIType, const std::string &URIContent="");
 
 	/**
 	 * @see Record#write
@@ -125,7 +125,7 @@
 	virtual uint16_t write(uint8_t *buffer);
 
     /**
-     * get the record type
+     * Get the record type.
      * @return TYPE_URI
 	 */
 	virtual RecordType_t getType() const {
@@ -133,26 +133,21 @@
 	} //getType
 
 	/**
-	 * if the record contains a know uri type this will tell you
-	 * the uri type, it it return {@code UNKNOWN} you can use
-	 * {@link RecordURI#getUriType}
-	 * @return uri type inside this record
+	 * Returns the URI type.
+	 * @return URI type inside this record, {@code UNKNOWN} if unknown
 	 */
 	knowUriId_t getUriId() const {
 		return mUriTypeId;
 	}
 
-	/**
-	 * @return update the record content and return the number of
-	 * bytes needed for store this record
-	 */
 	virtual uint16_t getByteLength() {
 		updateContentAndHeader();
 		return mRecordHeader.getRecordLength();
 	}
 
 	/**
-	 * @return uri content
+	 * Returns the URI content.
+	 * @return URI content
 	 */
 	std::string& getContent() {
 		updateContentAndHeader();
@@ -160,21 +155,21 @@
 	}
 
 	/**
-	 * change the uri content
-	 * @param uri new uri content
+	 * Change the URI content.
+	 * @param URI new URI content.
 	 */
-	void setContent(const std::string &uri){
+	void setContent(const std::string &URI){
 		if(mUriTypeId!=UNKNOWN)
-			storeRemoveingPrefix(sKnowUriPrefix[mUriTypeId],uri);
+			storeRemoveingPrefix(sKnowUriPrefix[mUriTypeId],URI);
 		else
-			mContent=uri;
+			mContent=URI;
 		updateContentAndHeader();
 	}
 
 	/**
-	 * if the uri type Id is {@code UNKNOWN} this return the user
-	 * uri type
-	 * @return uri type set by the user or an empyt string
+	 * If the URI type Id is {@code UNKNOWN} this return the user
+	 * URI type.
+	 * @return URI type set by the user or an empyt string
 	 */
 	const std::string& getUriType() const {
 		return mTypeString;
@@ -193,20 +188,20 @@
 protected:
 
 	/**
-	 * record id to write for be recognize as an uri record
+	 * Record id to write to be recognizable as an URI record.
 	 */
 	static const uint8_t sNDEFUriIdCode;
 
 	/**
-	 * a subclass must implement this function for store the tag content inside the mContent
-	 * variable, in this way this class will handle to write the tag
-	 * @par you should not call this function directly but use updateContentAndHeader that keep the
-	 * header information in sync with the content
+	 * A subclass must implement this function to store the tag content and update the mContent
+	 * variable accordingly.
+	 * @par You should not call this function directly but use updateContentAndHeader that keeps the
+	 * header information in sync with the content.
 	 */
 	virtual void updateContent(){};
 
 	/**
-	 * update the tag content and update the header with the new content size
+	 * Update the tag content and update the header with the new content size.
 	 */
 	void updateContentAndHeader(){
 		updateContent();
@@ -214,23 +209,23 @@
 	}
 
 	/**
-	 * the subclass have to store in this variable the content to write in the tag.
-	 * this class will ask to update the content thought the updateContent call
+	 * The subclass must store in this variable the content to write to the tag.
+	 * This class will ask to update the content throught the updateContent callback.
 	 */
 	std::string mContent;
 
 private:
 
 	/**
-	 * set the record header flags
+	 * Set the record header flags.
 	 */
 	void setRecordHeader();
 
 	/**
-	 * set the correct size of the payload
+	 * Set the correct size of the payload.
 	 */
 	void updateRecordHeader(){
-		//+1 = size of the uriTypeId
+		//+1 = size of the URITypeId
 		mRecordHeader.setPayloadLength(1 + mTypeString.size() + mContent.size());
 	}
 
@@ -243,18 +238,18 @@
 	}
 
 	/**
-	 * uri type used by this record
+	 * URI type used by this record
 	 */
 	const knowUriId_t mUriTypeId;
 
 	/**
-	 * in case of unknown uri type, it store the used define uri type
+	 * In case of unknown URI type, it stores the used defined URI type.
 	 */
 	const std::string mTypeString;
 
 
 	/**
-	 * array of know prefix for the know uri type
+	 * Array of known prefix of known URI type
 	 */
 	static const std::string sKnowUriPrefix[];
 };