This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

Dependencies:   NDefLib X_NUCLEO_NFC01A1 mbed

Fork of X-MBED-NFC1 by Giovanni Visentini

This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

The available demos are:

  • SAMPLE_WRITE_URL: write a tag with the ST home page URL
  • SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
  • SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
  • SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.

To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .

Files at this revision

API Documentation at this revision

Comitter:
giovannivisentini
Date:
Tue Dec 01 08:30:54 2015 +0000
Parent:
1:6d202b62ed68
Child:
3:f7f818ee694e
Commit message:
change the tag content when the user press the button

Changed in this revision

Common/nfc.h Show annotated file Show diff for this revision Revisions of this file
Interfaces/Nfc_class.h Show annotated file Show diff for this revision Revisions of this file
NDefLib.lib Show annotated file Show diff for this revision Revisions of this file
Type4NfcTagSTM24SR.cpp Show annotated file Show diff for this revision Revisions of this file
Type4NfcTagSTM24SR.h Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_NFC01A1.cpp Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_NFC01A1.h Show annotated file Show diff for this revision Revisions of this file
m24sr/m24sr_class.cpp Show annotated file Show diff for this revision Revisions of this file
m24sr/m24sr_class.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Common/nfc.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/Common/nfc.h	Tue Dec 01 08:30:54 2015 +0000
@@ -66,7 +66,7 @@
  */
 typedef void* NFC_InitTypeDef;
 /**
- * @brief  Humidity and temperature status enumerator definition
+ * @brief  NFC status enumerator definition
  */
 typedef enum {
 	NFC_SUCCESS=0x0000,
@@ -93,7 +93,6 @@
 	NFC_CLASS_NOT_SUPPORTED=0x6E00,
 
 	//IOError
-
 	NFC_IO_ERROR_I2CTIMEOUT=0x0011,
 	NFC_IO_ERROR_CRC=0x0012,
 	NFC_IO_ERROR_NACK=0x0013,
--- a/Interfaces/Nfc_class.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/Interfaces/Nfc_class.h	Tue Dec 01 08:30:54 2015 +0000
@@ -39,16 +39,6 @@
 
 /* Generated with Stm32CubeTOO -----------------------------------------------*/
 
-
-/* Revision ------------------------------------------------------------------*/
-/*
-	Repository:       http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
-	Branch/Trunk/Tag: trunk
-	Based on:         X-CUBE-MEMS1/trunk/Drivers/BSP/Components/Common/nfc.h
-	Revision:         385
-*/
-
-
 /* Define to prevent from recursive inclusion --------------------------------*/
 
 #ifndef __NFC_CLASS_H
@@ -68,33 +58,91 @@
 {
 public:
 
+	/**
+	 * possible password to set
+	 */
 	typedef enum{
-		ReadPwd=READ_PWD,
-		WritePwd=WRITE_PWD,
-		I2CPwd=I2C_PWD,
+		ReadPwd=READ_PWD,  //!< password to use before read the tag
+		WritePwd=WRITE_PWD,//!< password to use before write the tag
+		I2CPwd=I2C_PWD,    //!< root password, used only thought nfc
 	}PasswordType_t;
 
-	/* ACTION 1 --------------------------------------------------------------*
-	 * Declare here the interface's methods.                                  *
-	 * They should be:                                                        *
-	 *   + Methods with the same name of the C component's virtual table      *
-	 *     (and extended virtual table, if any)'s functions, provided that    *
-	 *     the component's driver implements them (i.e.: the corresponding    *
-	 *     pointer to function is not "0").                                   *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *    virtual int GetValue(float *pfData) = 0;                            *
-	 *------------------------------------------------------------------------*/
+
+	/**
+	 * open a i2c connection with the tag if an RF connection isn't already open
+	 * @return operation status
+	 */
 	virtual NFC_StatusTypeDef GetSession(void) = 0;
+	/**
+	 * force to open an i2c connection , abort the RF connection
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef KillSession(void) = 0;
+
+	/**
+	 * close an i2c connection
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef Deselect(void) = 0;
+
+	/**
+	 * Select the application file
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef SelectApplication(void) = 0;
+
+	/**
+	 * select the CC file
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef SelectCCfile(void) = 0;
+
+	/**
+	 * select the ndef file
+	 * @param NDEFfileId file id to open
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef SelectNDEFfile(uint16_t NDEFfileId) = 0;
+
+	/**
+	 * select the system file
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef SelectSystemfile(void) = 0;
+
+	/**
+	 * read data from the tag
+	 * @param Offset offset where start to read
+	 * @param NbByteToRead number of byte to read
+	 * @param[out] pBufferRead buffer where store the read data
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef ReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) = 0;
+
+	/**
+	 * write data to the tag
+	 * @param Offset offset where start to write
+	 * @param NbByteToWrite number of byte to write
+	 * @param pDataToWrite buffer to write
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef UpdateBinary(uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite) = 0;
+
+	/**
+	 * check that the password is correct
+	 * @param uPwdId password type
+	 * @param NbPwdByte password size ( must be 0x10)
+	 * @param pPwd password buffer
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef Verify(PasswordType_t uPwdId, uint8_t NbPwdByte,const uint8_t *pPwd) = 0;
+
+	/**
+	 * change the pa
+	 * @param uPwdId
+	 * @param pPwd
+	 * @return
+	 */
 	virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t uPwdId,const uint8_t *pPwd) = 0;
 	virtual NFC_StatusTypeDef EnableVerificationRequirement(PasswordType_t uReadOrWrite) = 0;
 	virtual NFC_StatusTypeDef DisableVerificationRequirement(PasswordType_t uReadOrWrite) = 0;
--- a/NDefLib.lib	Fri Nov 27 15:10:25 2015 +0000
+++ b/NDefLib.lib	Tue Dec 01 08:30:54 2015 +0000
@@ -1,1 +1,1 @@
-NDefLib#64bb6d5224dc
+NDefLib#eaf6c49a86e4
--- a/Type4NfcTagSTM24SR.cpp	Fri Nov 27 15:10:25 2015 +0000
+++ b/Type4NfcTagSTM24SR.cpp	Tue Dec 01 08:30:54 2015 +0000
@@ -16,7 +16,7 @@
 
 bool Type4NfcTagSTM24SR::openSession(bool force) {
 
-	if (mSessionIsOpen)
+	if (isSessionOpen())
 		return true;
 	//else
 	if (force)
@@ -54,29 +54,28 @@
 	if (mDevice.SelectNDEFfile(ndefFileId) != NFC_SUCCESS)
 		return false;
 
-	mSessionIsOpen = true;
+	Type4NfcTag::openSession();
 	return true;
 }
 
 bool Type4NfcTagSTM24SR::closeSession() {
 
 	//no open session
-	if (!mSessionIsOpen)
+	if (!isSessionOpen())
 		return true;
 
 	//close the CC file
 	if (mDevice.Deselect() != NFC_SUCCESS)
 		return false;
 
-	mSessionIsOpen = false;
+	Type4NfcTag::closeSession();
 	return true;
 }
 
-bool Type4NfcTagSTM24SR::writeByte(uint8_t *buffer, uint16_t length) {
+bool Type4NfcTagSTM24SR::writeByte(const uint8_t *buffer, uint16_t length, uint16_t offset) {
 
 	NFC_StatusTypeDef status = NFC_SUCCESS;
-	uint16_t offset = 0;
-	bool prevSessionStatus = mSessionIsOpen;
+	bool prevSessionStatus = isSessionOpen();
 	if (!prevSessionStatus) {
 		//try to acquire a session or fail
 		if (openSession(false))
@@ -85,7 +84,7 @@
 
 	if (length > mMaxWriteBytes) {
 		do {
-			status = mDevice.UpdateBinary(offset, mMaxWriteBytes, buffer);
+			status = mDevice.UpdateBinary(offset, mMaxWriteBytes,(uint8_t*) buffer);
 			offset += mMaxWriteBytes;
 			buffer += mMaxWriteBytes;
 			length -= mMaxWriteBytes;
@@ -94,7 +93,7 @@
 
 	//finish to write the buffer
 	if (status == NFC_SUCCESS && mMaxWriteBytes)
-		status = mDevice.UpdateBinary(offset, length, buffer);
+		status = mDevice.UpdateBinary(offset, length,(uint8_t*) buffer);
 
 	if (status == NFC_SUCCESS) {
 		if (!prevSessionStatus) // if the session was closed, try close it
--- a/Type4NfcTagSTM24SR.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/Type4NfcTagSTM24SR.h	Tue Dec 01 08:30:54 2015 +0000
@@ -12,26 +12,36 @@
 
 #include "NDefLib/Type4NfcTag.h"
 
+/**
+ * implement the abstract method for use the NDefLib
+ */
 class Type4NfcTagSTM24SR: public NDefLib::Type4NfcTag {
 
 public:
+	/**
+	 *
+	 * @param device device where write the Ndef tags
+	 */
 	Type4NfcTagSTM24SR(M24SR &device) :
-			mDevice(device), mSessionIsOpen(false), mMaxReadBytes(0xFF), mMaxWriteBytes(
+			mDevice(device), mMaxReadBytes(0xFF), mMaxWriteBytes(
 					0xFF) {
 	}
 
+
 	virtual bool openSession(bool force = false);
 	virtual bool closeSession();
 
+	/**
+	 * close the open session
+	 */
 	virtual ~Type4NfcTagSTM24SR() {
-		if (mSessionIsOpen)
+		if(isSessionOpen())
 			closeSession();
-	}
-	;
+	}//~Type4NfcTagSTM24SR
 
 	bool enableReadPassword(const uint8_t* pCurrentWritePassword,
 			const uint8_t* pNewPassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword)
@@ -48,7 +58,7 @@
 	}
 
 	bool disableReadPassword(const uint8_t* pCurrentWritePassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword)
@@ -64,7 +74,7 @@
 
 	bool enableWritePassword(const uint8_t* pCurrentWritePassword,
 			uint8_t* pNewPassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		/* check we have the good password */
@@ -73,7 +83,6 @@
 			/* Set new password */
 			if (mDevice.ChangeReferenceData(M24SR::WritePwd, pNewPassword)
 					== NFC_SUCCESS)
-				;
 			return mDevice.EnableVerificationRequirement(M24SR::WritePwd)
 					== NFC_SUCCESS;
 		}
@@ -81,7 +90,7 @@
 	}
 
 	bool disableWritePassword(const uint8_t* pCurrentWritePassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword)
@@ -98,7 +107,7 @@
 	 * @retval ERROR : operation does not complete
 	 */
 	bool disableAllPassword(const uint8_t* pSuperUserPassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pSuperUserPassword)
@@ -124,7 +133,7 @@
 	 * @retval ERROR : operation does not complete
 	 */
 	bool enableReadOnly(const uint8_t* pCurrentWritePassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword)
@@ -142,7 +151,7 @@
 	 * @retval ERROR : operation does not complete
 	 */
 	bool disableReadOnly() {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD)
@@ -162,7 +171,7 @@
 	 * @retval ERROR : operation does not complete
 	 */
 	bool enableWriteOnly(const uint8_t* pCurrentWritePassword) {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword)
@@ -180,7 +189,7 @@
 	 * @retval ERROR : operation does not complete
 	 */
 	bool disableWriteOnly() {
-		if (!mSessionIsOpen)
+		if (!isSessionOpen())
 			return false;
 
 		if (mDevice.Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD)
@@ -194,15 +203,22 @@
 	}
 
 protected:
-	virtual bool writeByte(uint8_t *buffer, const uint16_t lenght);
+	virtual bool writeByte(const uint8_t *buffer, const uint16_t length, uint16_t offset);
 	virtual bool readByte(const uint16_t byteOffset, const uint16_t byteLength,
 			uint8_t *buffer);
 
 private:
 
 	M24SR &mDevice;
-	bool mSessionIsOpen;
+
+	/**
+	 * max length for a read operation
+	 */
 	uint16_t mMaxReadBytes;
+
+	/**
+	 * max length for a write operation
+	 */
 	uint16_t mMaxWriteBytes;
 };
 
--- a/X_NUCLEO_NFC01A1.cpp	Fri Nov 27 15:10:25 2015 +0000
+++ b/X_NUCLEO_NFC01A1.cpp	Tue Dec 01 08:30:54 2015 +0000
@@ -7,18 +7,20 @@
 
 #include <X_NUCLEO_NFC01A1.h>
 
+const uint8_t  X_NUCLEO_NFC01A1::M24SR_ADDR=0xAC;
+
 X_NUCLEO_NFC01A1 *X_NUCLEO_NFC01A1::mInstance = NULL;
 
 X_NUCLEO_NFC01A1* X_NUCLEO_NFC01A1::Instance(I2C &devI2C,
 		const PinName &gpoName, const PinName &RFDisableName,
 		const PinName &led1Name, const PinName &led2Name,
 		const PinName &led3Name) {
-	if (mInstance == NULL) {
+	if (mInstance == NULL) { // the first time
 		mInstance = new X_NUCLEO_NFC01A1(devI2C, gpoName, RFDisableName,
 				led1Name, led2Name, led3Name);
-		if (mInstance != NULL) {
+		if (mInstance != NULL) { //allocation ok
 			const int status = mInstance->mM24SR.Init(NULL);
-			if (status != NFC_SUCCESS) {
+			if (status != NFC_SUCCESS) { //initialization failed
 				delete mInstance;
 				error(
 						"Failed to init X_NUCLEO_NFC01A1 expansion board!\r\nError:0x%X\r\n",
--- a/X_NUCLEO_NFC01A1.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/X_NUCLEO_NFC01A1.h	Tue Dec 01 08:30:54 2015 +0000
@@ -7,18 +7,37 @@
 
 #ifndef X_NUCLEO_NFC01A1_H_
 #define X_NUCLEO_NFC01A1_H_
+#include <stdint.h>
 
 #include "mbed.h"
 
 #include "m24sr/m24sr_class.h"
 
-#define M24SR_ADDR 0xAC   /*!< M24SR address */
-
+/**
+ * singleton class that controls all the electronics inside the X_NUCLEO_NFC01A1 expansion board
+ */
 class X_NUCLEO_NFC01A1 {
 
 private:
+	/**
+	 * ponter to the singleton instance, NULL if we did't build one
+	 */
 	static X_NUCLEO_NFC01A1 *mInstance;
+	/**
+	 * i2c address of the m24sr chip
+	 */
+	static const uint8_t M24SR_ADDR;
 
+	/**
+	 * constructor
+	 * @param devI2C i2c channel used for communicate with the board
+	 * @param gpoName pin of the gpio pin of the M24SR chip
+	 * @param RFDisableName pin for disable the rf antenna
+	 * @param led1Name pin for control the led1 status
+	 * @param led2Name pin for control the led1 status
+	 * @param led3Name pin for control the led1 status
+	 */
+	//TODO FIX all this the pin name?
 	X_NUCLEO_NFC01A1(I2C &devI2C, const PinName &gpoName,
 			const PinName &RFDisableName, const PinName &led1Name,
 			const PinName &led2Name, const PinName &led3Name) :
@@ -28,20 +47,35 @@
 	}
 
 public:
+	//TODO FIX all this the pin name?
 	static X_NUCLEO_NFC01A1* Instance(I2C &devI2C, const PinName &gpoName = D12,
 			const PinName &RFDisableName = D11, const PinName &led1Name = D5,
 			const PinName &led2Name = D4, const PinName &led3Name = D2);
 
+	/**
+	 * @return board led1
+	 */
 	DigitalOut& getLed1() {
 		return mNfcLed1;
 	}
+
+	/**
+	 * @return board led2
+	 */
 	DigitalOut& getLed2() {
 		return mNfcLed2;
 	}
+
+	/**
+	 * @return board led3
+	 */
 	DigitalOut& getLed3() {
 		return mNfcLed3;
 	}
 
+	/**
+	 * @return NFC Chip
+	 */
 	M24SR& getM24SR() {
 		return mM24SR;
 	}
--- a/m24sr/m24sr_class.cpp	Fri Nov 27 15:10:25 2015 +0000
+++ b/m24sr/m24sr_class.cpp	Tue Dec 01 08:30:54 2015 +0000
@@ -36,20 +36,15 @@
  ******************************************************************************
  */
 
-/* Generated with Stm32CubeTOO -----------------------------------------------*/
 
-/* Revision ------------------------------------------------------------------*/
-/*
- Repository:       http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
- Branch/Trunk/Tag: trunk
- Based on:         X-CUBE-MEMS1/trunk/Drivers/BSP/Components/m24sr/m24sr.c
- Revision:         :410
- */
 
 /* Includes ------------------------------------------------------------------*/
 #include "m24sr_class.h"
 #include "m24sr.h"
 
+/**
+ * default password, it is used also for reach the super user mode throught the i2c channel
+ */
 const uint8_t M24SR::DEFAULT_PASSWORD[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
@@ -64,7 +59,12 @@
  */
 
 #ifndef errchk
+
+/** value return by the NFC chip when a command is successfully done */
 #define NFC_COMMAND_SUCCESS 0x9000
+
+/** call the fCall funtion and check that the return status is NFC_COMMAND_SUCCESS,
+ *  otherwise return the error status*/
 #define errchk(fCall) {\
 	const NFC_StatusTypeDef status = (fCall); \
 	if((status!=NFC_SUCCESS)) \
@@ -108,7 +108,7 @@
 /**  
  * @brief  	This function computes the CRC16 residue as defined by CRC ISO/IEC 13239
  * @param  	DataIn		:	input to data 
- * @param		Length 		: 	Number of bits of DataIn
+ * @param	Length 		: 	Number of bits of DataIn
  * @retval 	Status (SW1&SW2)  	:   CRC16 residue is correct	
  * @retval 	M24SR_ERROR_CRC  	:  CRC16 residue is false
  */
@@ -266,7 +266,7 @@
  * @brief  This function sends the FWT extension command (S-Block format)
  * @param	FWTbyte : FWT value
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_FWTExtension(uint8_t FWTbyte) {
 	uint8_t pBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -301,8 +301,8 @@
 /**
  * @brief  This function sends the KillSession command to the M24SR device
  * @param  None
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_KillSession(void) {
 	uint8_t commandBuffer[] = M24SR_KILLSESSION_COMMAND;
@@ -319,8 +319,8 @@
 
 /**
  * @brief  This function sends the Deselect command (S-Block format)
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_Deselect(void) {
 	uint8_t pBuffer[] = M24SR_DESELECTREQUEST_COMMAND;
@@ -337,8 +337,8 @@
 
 /**
  * @brief  This function sends the SelectApplication command
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_SelectApplication(void) {
 
@@ -408,7 +408,7 @@
 
 /**
  * @brief  This function sends the GetSession command to the M24SR device
- * @retval NFC_OK : the function is succesful.
+ * @retval NFC_SUCCESS : the function is successful.
  * @retval Status (SW1&SW2) : if operation does not complete.
  */
 NFC_StatusTypeDef M24SR::M24SR_GetSession(void) {
@@ -427,8 +427,8 @@
 
 /**
  * @brief  This function sends the SelectCCFile command
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  * @retval Status (SW1&SW2) : if operation does not complete for another reason.
  */
 NFC_StatusTypeDef M24SR::M24SR_SelectCCfile(void) {
@@ -471,7 +471,7 @@
 /**
  * @brief  This function sends the SelectSystemFile command
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_SelectSystemfile(void) {
 	C_APDU command;
@@ -513,7 +513,7 @@
 /**
  * @brief  This function sends the SelectNDEFfile command
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_SelectNDEFfile(uint16_t NDEFfileId) {
 	C_APDU command;
@@ -557,7 +557,7 @@
  * @param	NbByteToRead : number of byte to read
  * @param	pBufferRead : pointer of the buffer read from the M24SR device
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_ReadBinary(uint16_t Offset, uint8_t NbByteToRead,
 		uint8_t *pBufferRead) {
@@ -599,7 +599,7 @@
  * @param	NbByteToRead : number of byte to read
  * @param	pBufferRead : pointer of the buffer read from the M24SR device
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured. 
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_STReadBinary(uint16_t Offset,
 		uint8_t NbByteToRead, uint8_t *pBufferRead) {
@@ -641,7 +641,7 @@
  * @param	NbByteToWrite : number of byte to write
  * @param	pBufferRead : pointer of the buffer read from the M24SR device
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_UpdateBinary(uint16_t Offset,
 		uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
@@ -699,7 +699,7 @@
  * @param	NbPwdByte : Number of byte ( 0x00 or 0x10)
  * @param	pPwd : pointer on the passwaord
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_Verify(uint16_t uPwdId, uint8_t NbPwdByte,
 		const uint8_t *pPwd) {
@@ -760,7 +760,7 @@
  * @param	uPwdId : PasswordId ( 0x0001 : Read NDEF pwd or 0x0002 : Write NDEF pwd or 0x0003 : I2C pwd)
  * @param	pPwd : pointer on the passwaord
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_ChangeReferenceData(uint16_t uPwdId,
 		uint8_t *pPwd) {
@@ -807,7 +807,7 @@
  * @brief  This function sends the EnableVerificationRequirement command
  * @param	uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write  )
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_EnableVerificationRequirement(
 		uint16_t uReadOrWrite) {
@@ -850,7 +850,7 @@
  * @brief  This function sends the DisableVerificationRequirement command
  * @param	uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write  )
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_DisableVerificationRequirement(
 		uint16_t uReadOrWrite) {
@@ -895,7 +895,7 @@
  * @brief  This function sends the EnablePermananentState command
  * @param	uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write  )
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_EnablePermanentState(uint16_t uReadOrWrite) {
 	C_APDU command;
@@ -937,7 +937,7 @@
  * @brief  This function sends the DisablePermanentState command
  * @param	uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write  )
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_DisablePermanentState(uint16_t uReadOrWrite) {
 	C_APDU command;
@@ -980,7 +980,7 @@
  * @brief  This function generates a interrupt on GPO pin
  * @param	None
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
 	C_APDU command;
@@ -1023,7 +1023,7 @@
  * @brief  This function force GPO pin to low state or high Z
  * @param	uSetOrReset : select if GPO must be low (reset) or HiZ
  * @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
  */
 NFC_StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
 	C_APDU command;
--- a/m24sr/m24sr_class.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/m24sr/m24sr_class.h	Tue Dec 01 08:30:54 2015 +0000
@@ -36,14 +36,10 @@
  ******************************************************************************
  */
 
-/* Generated with Stm32CubeTOO -----------------------------------------------*/
-
 /* Revision ------------------------------------------------------------------*/
 /*
- Repository:       http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
- Branch/Trunk/Tag: trunk
  Based on:         X-CUBE-MEMS1/trunk/Drivers/BSP/Components/m24sr/m24sr.h
- Revision:         402
+ Revision:         M24SR Driver V1.0.0
  */
 
 /* Define to prevent recursive inclusion -------------------------------------*/
@@ -53,22 +49,10 @@
 
 /* Includes ------------------------------------------------------------------*/
 
-/* ACTION 1 ------------------------------------------------------------------*
- * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/
 #include "mbed.h"
 #include "I2C.h"
-/* ACTION 2 ------------------------------------------------------------------*
- * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/
+
 #include "m24sr.h"
-/* ACTION 3 ------------------------------------------------------------------*
- * Include here interface specific header files.                              *
- *                                                                            *
- * Example:                                                                   *
- *   #include "../Interfaces/Humidity_class.h"                                *
- *   #include "../Interfaces/Temperature_class.h"                             *
- *----------------------------------------------------------------------------*/
 #include "Interfaces/Nfc_class.h"
 
 /* Classes -------------------------------------------------------------------*/
@@ -92,16 +76,7 @@
 			Nfc(), address(address), dev_i2c(i2c), GPOPin(GPOPinName), RFDisablePin(
 					RFDISPinName), answerReadyInterrupt(GPOPinName), interruptIsFired(
 					false) {
-		/* ACTION 4 ----------------------------------------------------------*
-		 * Initialize here the component's member variables, one variable per *
-		 * line.                                                              *
-		 *                                                                    *
-		 * Example:                                                           *
-		 *   T0_out = 0;                                                      *
-		 *   T1_out = 0;                                                      *
-		 *   T0_degC = 0;                                                     *
-		 *   T1_degC = 0;                                                     *
-		 *--------------------------------------------------------------------*/
+
 		memset(uM24SRbuffer, 0, 0xFF * sizeof(int8_t));
 		syncMode = M24SR_WAITINGTIME_POLLING;
 		uDIDbyte = 0;
@@ -121,27 +96,6 @@
 	}
 
 	/*** Public Component Related Methods ***/
-
-	/* ACTION 5 --------------------------------------------------------------*
-	 * Implement here the component's public methods, as wrappers of the C    *
-	 * component's functions.                                                 *
-	 * They should be:                                                        *
-	 *   + Methods with the same name of the C component's virtual table's    *
-	 *     functions (1);                                                     *
-	 *   + Methods with the same name of the C component's extended virtual   *
-	 *     table's functions, if any (2).                                     *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   virtual int GetValue(float *pData) //(1)                             *
-	 *   {                                                                    *
-	 *     return COMPONENT_GetValue(float *pfData);                          *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   virtual int EnableFeature(void) //(2)                                *
-	 *   {                                                                    *
-	 *     return COMPONENT_EnableFeature();                                  *
-	 *   }                                                                    *
-	 *------------------------------------------------------------------------*/
 	virtual int Init(void *ptr) {
 		return (NFC_StatusTypeDef) M24SR_Init((NFC_InitTypeDef*)ptr);
 	}
@@ -217,7 +171,7 @@
 				(uint16_t) uReadOrWrite);
 	}
 
-	/** st propietary */
+	/** st proprietary */
 	virtual NFC_StatusTypeDef STReadBinary(uint16_t Offset,
 			uint8_t NbByteToRead, uint8_t *pBufferRead) {
 		return (NFC_StatusTypeDef) M24SR_STReadBinary((uint16_t) Offset,
@@ -253,61 +207,15 @@
 		return (NFC_StatusTypeDef) M24SR_RFConfig((uint8_t) OnOffChoice);
 	}
 
+	/*** Public Interrupt Related Methods ***/
 	virtual NFC_StatusTypeDef SendInterrupt(void) {
 		return (NFC_StatusTypeDef) M24SR_SendInterrupt();
 	}
 
-	/*** Public Interrupt Related Methods ***/
-
-	/* ACTION 6 --------------------------------------------------------------*
-	 * Implement here interrupt related methods, if any.                      *
-	 * Note that interrupt handling is platform dependent, e.g.:              *
-	 *   + mbed:                                                              *
-	 *     InterruptIn feature_int(pin); //Interrupt object.                  *
-	 *     feature_int.rise(callback);   //Attach a callback.                 *
-	 *     feature_int.mode(PullNone);   //Set interrupt mode.                *
-	 *     feature_int.enable_irq();     //Enable interrupt.                  *
-	 *     feature_int.disable_irq();    //Disable interrupt.                 *
-	 *   + Arduino:                                                           *
-	 *     attachInterrupt(pin, callback, RISING); //Attach a callback.       *
-	 *     detachInterrupt(pin);                   //Detach a callback.       *
-	 *                                                                        *
-	 * Example (mbed):                                                        *
-	 *   void Attach_Feature_IRQ(void (*fptr) (void))                         *
-	 *   {                                                                    *
-	 *     feature_int.rise(fptr);                                            *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   void Enable_Feature_IRQ(void)                                        *
-	 *   {                                                                    *
-	 *     feature_int.enable_irq();                                          *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   void Disable_Feature_IRQ(void)                                       *
-	 *   {                                                                    *
-	 *     feature_int.disable_irq();                                         *
-	 *   }                                                                    *
-	 *------------------------------------------------------------------------*/
-
 protected:
 
 	/*** Protected Component Related Methods ***/
 
-	/* ACTION 7 --------------------------------------------------------------*
-	 * Declare here the component's specific methods.                         *
-	 * They should be:                                                        *
-	 *   + Methods with the same name of the C component's virtual table's    *
-	 *     functions (1);                                                     *
-	 *   + Methods with the same name of the C component's extended virtual   *
-	 *     table's functions, if any (2);                                     *
-	 *   + Helper methods, if any, like functions declared in the component's *
-	 *     source files but not pointed by the component's virtual table (3). *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   DrvStatusTypeDef COMPONENT_GetValue(float* pfData); //(1)            *
-	 *   DrvStatusTypeDef COMPONENT_EnableFeature(void);     //(2)            *
-	 *   DrvStatusTypeDef COMPONENT_ComputeAverage(void);    //(3)            *
-	 *------------------------------------------------------------------------*/
 	NFC_StatusTypeDef M24SR_Init(NFC_InitTypeDef *);
 	NFC_StatusTypeDef M24SR_ReadID(uint8_t *nfc_id);
 	NFC_StatusTypeDef M24SR_GetSession(void);
@@ -339,15 +247,10 @@
 	NFC_StatusTypeDef M24SR_RFConfig(uint8_t OnOffChoice);
 	NFC_StatusTypeDef M24SR_FWTExtension(uint8_t FWTbyte);
 
-	/* ACTION 8 --------------------------------------------------------------*
-	 * Implement here other I/O methods beyond those already implemented      *
-	 * above, which are declared extern within the component's header file.   *
-	 *------------------------------------------------------------------------*/
 
+	// platform specific IO method
 	NFC_StatusTypeDef M24SR_IO_IsAnswerReady(void);
-
 	NFC_StatusTypeDef M24SR_IO_SendI2Ccommand(uint8_t NbByte, uint8_t *pBuffer);
-
 	NFC_StatusTypeDef M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte,
 			uint8_t *pBuffer);
 
@@ -371,6 +274,9 @@
 		syncMode = mode;
 	}
 
+	/**
+	 * callback trigger when the chip finish to do a command
+	 */
 	void M24SR_AnswerReadyInterruptCallback() {
 		interruptIsFired = true;
 		answerReadyInterrupt.disable_irq();
@@ -381,14 +287,10 @@
 	/* Identity */
 	uint8_t who_am_i;
 
-	/* ACTION 9 --------------------------------------------------------------*
-	 * There should be only a unique identifier for each component, which     *
-	 * should be the "who_am_i" parameter, hence this parameter is optional.  *
-	 *------------------------------------------------------------------------*/
 	/* Type. */
 	uint8_t type;
 
-	/* Configuration. */
+	/* I2C address */
 	uint8_t address;
 
 	/* IO Device. */
@@ -396,34 +298,36 @@
 
 	/* GPIO */
 	DigitalIn GPOPin;
+
+	/**
+	 * pin used for disable the rf chip functionality
+	 */
 	DigitalOut RFDisablePin;
+
+	/**
+	 * pin used as interrupt
+	 */
 	InterruptIn answerReadyInterrupt;
+
+	/**
+	 * method used for wait the chip response
+	 */
 	M24SR_WAITINGTIME_MGMT syncMode;
 
-	/* Interrupts. */
-	/* ACTION 10 -------------------------------------------------------------*
-	 * Put here interrupt related objects, if needed.                         *
-	 * Note that interrupt handling is platform dependent, see                *
-	 * "Interrupt Related Methods" above.                                     *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   + mbed:                                                              *
-	 *     InterruptIn feature_int;                                           *
-	 *------------------------------------------------------------------------*/
+	/**
+	 * buffer used for build the command to send to the chip
+	 */
+	uint8_t uM24SRbuffer[0xFF];
 
-	/* Data. */
-	/* ACTION 11 -------------------------------------------------------------*
-	 * Declare here the component's data, one variable per line.              *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   int T0_out;                                                          *
-	 *   int T1_out;                                                          *
-	 *   float T0_degC;                                                       *
-	 *   float T1_degC;                                                       *
-	 *------------------------------------------------------------------------*/
-	uint8_t uM24SRbuffer[0xFF];
+	/**
+	 * ???
+	 */
 	uint8_t uDIDbyte;
-	bool interruptIsFired;
+
+	/**
+	 * state variable change when the interrupt is fired
+	 */
+	volatile bool interruptIsFired;
 };
 
 #endif // __M24SR_CLASS_H
--- a/main.cpp	Fri Nov 27 15:10:25 2015 +0000
+++ b/main.cpp	Tue Dec 01 08:30:54 2015 +0000
@@ -21,6 +21,7 @@
 
 DigitalOut myled(LED1);
 
+
 void shiftLed(DigitalOut &led1,DigitalOut &led2,DigitalOut &led3){
 	const uint8_t prevLed1=led1;
 	const uint8_t prevLed2=led2;
@@ -30,18 +31,13 @@
 	led3=prevLed2;
 }
 
-
 static const PinName M24SR_SDA=D14;
 static const PinName M24SR_SDL=D15;
 
 static const uint32_t MAX_WRITE_TRY=1;
 
-I2C i2cChannel(M24SR_SDA,M24SR_SDL);
-M24SR *m24srDrv;
+void setNFCTag(NDefLib::Type4NfcTag &tag){
 
-void setNFCTag(){
-
-	Type4NfcTagSTM24SR tag(*m24srDrv);
 	bool writeStatus,closeStatus;
 	if(tag.openSession()){
 		NDefLib::Message msg;
@@ -52,7 +48,7 @@
 		NDefLib::RecordSMS rSMS("123456789","st.com.BlueMS");
 		msg.addRecord(&rSMS);
 
-		NDefLib::RecordGeo rGeo("123.123","456.789");
+		NDefLib::RecordGeo rGeo(123.123,-456.789);
 		msg.addRecord(&rGeo);
 
 		NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"http://www.st.com");
@@ -61,22 +57,21 @@
 		NDefLib::RecordMail rMail("mail@st.com","ciao","da nfc tag");
 		msg.addRecord(&rMail);
 
-		NDefLib::RecordMimeType rText1("text/plain","ciao");
+		NDefLib::RecordMimeType rText1("text/plain",(const uint8_t*)"ciao",4);
 		msg.addRecord(&rText1);
 
 		NDefLib::RecordText rText3(NDefLib::RecordText::UTF8,"it","ciao");
 		msg.addRecord(&rText3);
 
-
 		NDefLib::RecordVCard::VCardInfo_t cardInfo;
-		cardInfo[NDefLib::RecordVCard::FORMATTED_NAME]="prova2 prova1";
+		cardInfo[NDefLib::RecordVCard::FORMATTED_NAME]="prova prova1";
 		cardInfo[NDefLib::RecordVCard::ADDRESS_HOME]=";;1 Main St.;Springfield;IL;12345;USA";
 		cardInfo[NDefLib::RecordVCard::ADDRESS_WORK]=";;2 Main St.;Springfield;IL;12345;USA";
 		cardInfo[NDefLib::RecordVCard::EMAIL_WORK]="workmail@st.com";
 		cardInfo[NDefLib::RecordVCard::EMAIL_HOME]="homemail@st.com";
 		cardInfo[NDefLib::RecordVCard::GEO]="39.95;-75.1667";
 		cardInfo[NDefLib::RecordVCard::IMPP]="aim:johndoe@aol.com";
-		cardInfo[NDefLib::RecordVCard::NAME]="prova4;prova5";
+		cardInfo[NDefLib::RecordVCard::NAME]="prova2;prova3";
 		cardInfo[NDefLib::RecordVCard::NICKNAME]="test";
 		cardInfo[NDefLib::RecordVCard::NOTE]="A good test";
 		cardInfo[NDefLib::RecordVCard::ORGANIZATION]="STM";
@@ -163,25 +158,25 @@
 			break;}
 		case Record::TYPE_URI_MAIL:{
 			RecordMail *temp = (RecordMail*)r;
-			pc.printf("Read Dest: %s\r\n",temp->getDest().c_str());
+			pc.printf("Read Dest: %s\r\n",temp->getToAddress().c_str());
 			pc.printf("Read Subject: %s\r\n",temp->getSubject().c_str());
 			pc.printf("Read Body: %s\r\n",temp->getBody().c_str());
 			break;}
-		case Record::TYPE_SMS:{
+		case Record::TYPE_URI_SMS:{
 			RecordSMS *temp = (RecordSMS*)r;
 			pc.printf("Read number: %s\r\n",temp->getNumber().c_str());
 			pc.printf("Read message: %s\r\n",temp->getMessagge().c_str());
 			break;}
-		case Record::TYPE_GEOLOCATION:{
+		case Record::TYPE_URI_GEOLOCATION:{
 			RecordGeo *temp = (RecordGeo*)r;
-			pc.printf("Read lat: %s\r\n",temp->getLatitude().c_str());
-			pc.printf("Read long: %s\r\n",temp->getLongitude().c_str());
+			pc.printf("Read lat: %f\r\n",temp->getLatitude());
+			pc.printf("Read long: %f\r\n",temp->getLongitude());
 			break;}
 		case Record::TYPE_MIME_VCARD:{
-			RecordVCard *temp = (RecordVCard*)r;
+			const RecordVCard *temp = (RecordVCard*)r;
 			pc.printf("Read Name: %s\r\n",(*temp)[RecordVCard::NAME].c_str());
 			pc.printf("Read Mail: %s\r\n",(*temp)[RecordVCard::EMAIL_WORK].c_str());
-			pc.printf("Read org: %s\r\n",(*temp)[RecordVCard::ORGANIZATION].c_str());
+			pc.printf("Read ORG: %s\r\n",(*temp)[RecordVCard::ORGANIZATION].c_str());
 			break;}
 		case Record::TYPE_UNKNOWN:{
 			pc.printf("Unknown record\r\n");
@@ -189,9 +184,55 @@
 	}//switch
 }
 
-void readNfcTag(){
+void changeRecord(NDefLib::Record *r){
 	using namespace NDefLib;
-	Type4NfcTagSTM24SR tag(*m24srDrv);
+	switch(r->getType()){
+		case Record::TYPE_TEXT:	{
+			RecordText *temp = (RecordText*)r;
+			temp->setText("CIAOCiao");
+			break; }
+		case Record::TYPE_AAR:{
+			RecordAAR *temp = (RecordAAR*)r;
+			temp->setPackage("set Package Ok");
+			break; }
+		case Record::TYPE_MIME:{
+			RecordMimeType *temp = (RecordMimeType*)r;
+			temp->copyMimeData((const uint8_t *)"String2",sizeof("String2"));
+			break;}
+		case Record::TYPE_URI:{
+			RecordURI *temp = (RecordURI*)r;
+			temp->setContent("google.it");
+			break;}
+		case Record::TYPE_URI_MAIL:{
+			RecordMail *temp = (RecordMail*)r;
+			temp->setToAddress("newMail@st.com");
+			temp->setSubject("tag change");
+			temp->setBody("read/change Works!");
+			break;}
+		case Record::TYPE_URI_SMS:{
+			RecordSMS *temp = (RecordSMS*)r;
+			temp->setMessage("Message Change");
+			temp->setNumber("0987654321");
+			break;}
+		case Record::TYPE_URI_GEOLOCATION:{
+			RecordGeo *temp = (RecordGeo*)r;
+			temp->setLatitude(-temp->getLatitude());
+			temp->setLongitude(-temp->getLongitude());
+			break;}
+		case Record::TYPE_MIME_VCARD:{
+			RecordVCard *temp = (RecordVCard*)r;
+			(*temp)[RecordVCard::NAME]="name change";
+			(*temp)[RecordVCard::NICKNAME]="nic change";
+			break;}
+		case Record::TYPE_UNKNOWN:{
+			pc.printf("Unknown record\r\n");
+			break;}
+	}//switch
+}
+
+void readNfcTag(NDefLib::Type4NfcTag &tag){
+	using namespace NDefLib;
+
 	if(tag.openSession()){
 		NDefLib::Message readMsg;
 
@@ -201,7 +242,7 @@
 			pc.printf("Error Read\r\n");
 		}else{
 			for(uint32_t i=0;i<readMsg.getNRecords();i++){
-				Record *r = readMsg.getRecord(i);
+				Record *r = readMsg[i];
 				printRecord(r);
 				delete r;
 			}//for
@@ -213,25 +254,62 @@
 	}
 }
 
+
+void changeNfcTag(NDefLib::Type4NfcTag &tag){
+	using namespace NDefLib;
+
+	if(tag.openSession()){
+		NDefLib::Message readMsg;
+
+		tag.read(&readMsg);
+
+		if(readMsg.getNRecords()==0){
+			pc.printf("Error Read\r\n");
+		}else{
+			for(uint32_t i=0;i<readMsg.getNRecords();i++){
+				Record *r = readMsg[i];
+				changeRecord(r);
+			}//for
+			tag.write(readMsg);
+		}//if-else
+
+		tag.closeSession();
+	}else{
+		pc.printf("Error open SessionChange\n\r");
+	}
+}
+
+static bool buttonPress=false;
+void setButtonPress(){
+	buttonPress=true;
+}
+
 int main() {
+	I2C i2cChannel(M24SR_SDA,M24SR_SDL);
 	i2cChannel.frequency(400000);
 	X_NUCLEO_NFC01A1 *nfcNucleo = X_NUCLEO_NFC01A1::Instance(i2cChannel);
-	m24srDrv=&nfcNucleo->getM24SR();
-
+	Type4NfcTagSTM24SR tag(nfcNucleo->getM24SR());
+	InterruptIn mybutton(USER_BUTTON);
 	pc.printf("Hello World !\n\r");
 	nfcNucleo->getLed1()=1;
 	nfcNucleo->getLed2()=0;
 	nfcNucleo->getLed3()=0;
 
-	setNFCTag();
-	readNfcTag();
-	//pc.printf("2!\n\r");
-	//setNFCTag();
-	//readNfcTag();
+	setNFCTag(tag);
+	readNfcTag(tag);
+
+	mybutton.fall(setButtonPress);
+
 	while(1) {
 		wait(1);
 		myled = !myled;
 		shiftLed(nfcNucleo->getLed1(),nfcNucleo->getLed2(),nfcNucleo->getLed3());
+		if(buttonPress){
+			changeNfcTag(tag);
+			readNfcTag(tag);
+			buttonPress=false;
+		}
 	}
 
 }
+