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:
4:eaf6c49a86e4
Parent:
1:a0eeb478a45a
Child:
5:f2b7efcc5b6e
--- a/RecordType/RecordMail.h	Fri Nov 27 15:09:55 2015 +0000
+++ b/RecordType/RecordMail.h	Tue Dec 01 08:30:27 2015 +0000
@@ -12,38 +12,77 @@
 
 namespace NDefLib {
 
+/**
+ * class that specialize the RecordUri for store the mail content
+ */
 class RecordMail: public RecordURI {
 
-
 public:
-	static RecordMail* parse(const Record::RecordHeader &header,const uint8_t* buffer);
+
+	/**
+	 * create an RecordMail reading the data from the buffer
+ 	 * @param header record header already read
+	 * @param buffer buffer where read the data
+	 * @return an object of type RecordMail or NULL
+	 * @par free the pointer return by this function
+	 */
+	static RecordMail* parse(const RecordHeader &header,
+			const uint8_t* buffer);
 
-	RecordMail(const std::string &dest,const std::string &subject, const std::string &msg):
-			RecordURI(RecordURI::MAIL,dest+sSubjectTag+subject+sBodyTag+msg),
-			mDest(dest),mSubject(subject),mBody(msg){};
-	virtual ~RecordMail(){};
+	/**
+	 * create a mail
+	 * @param toAddress where send the mail
+	 * @param subject mail subject
+	 * @param msg message
+	 */
+	RecordMail(const std::string &toAddress, const std::string &subject,
+			const std::string &msg) :
+			RecordURI(RecordURI::MAIL), mToAddress(toAddress), mSubject(
+					subject), mBody(msg),mContentIsChange(true) { }	;
 
-	const std::string& getDest()const{
-		return mDest;
+	virtual ~RecordMail() {	};
+
+	const std::string& getToAddress() const {
+		return mToAddress;
 	}
 
-	const std::string& getSubject()const{
+	const std::string& getSubject() const {
 		return mSubject;
 	}
 
-	const std::string& getBody()const{
+	const std::string& getBody() const {
 		return mBody;
 	}
 
-	virtual RecordType_t getType()const{
+	void setToAddress(const std::string& dest){
+		mContentIsChange=true;
+		mToAddress=dest;
+	}
+
+	void setSubject(const std::string& subj) {
+		mContentIsChange=true;
+		mSubject=subj;
+	}
+
+	void setBody(const std::string& body) {
+		mContentIsChange=true;
+		mBody=body;
+	}
+
+	virtual RecordType_t getType() const {
 		return TYPE_URI_MAIL;
-	}//getType
+	} //getType
+
+protected:
+	virtual void updateContent();
+
 
 private:
 
-	const std::string mDest;
-	const std::string mSubject;
-	const std::string mBody;
+	std::string mToAddress;
+	std::string mSubject;
+	std::string mBody;
+	bool mContentIsChange;
 
 	static const std::string sSubjectTag;
 	static const std::string sBodyTag;