Firmware library for the X-NUCLEO-NFC01A1 Dynamic NFC Tag board.

Dependencies:   M24SR

Dependents:   NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more

Fork of X_NUCLEO_NFC01A1 by ST Expansion SW Team

X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board based on M24SR.

Firmware Library

Class X_NUCLEO_NFC01A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24SR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC01A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24SR, providing an simple way to read/write NDEF formatted messages from/to the M24SR dynamic NFC tag.

Example applications

1. Hello World
2. Asynchronous Hello World

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Wed Jul 12 14:15:02 2017 +0000
Parent:
32:9fc4f9195d28
Child:
34:b76765d2cc68
Commit message:
Updated to fit ARM mbed coding style.

Changed in this revision

m24sr/M24SR.cpp Show annotated file Show diff for this revision Revisions of this file
m24sr/M24SR.h Show annotated file Show diff for this revision Revisions of this file
m24sr/NDefNfcTagM24SR.cpp Show annotated file Show diff for this revision Revisions of this file
m24sr/NDefNfcTagM24SR.h Show annotated file Show diff for this revision Revisions of this file
--- a/m24sr/M24SR.cpp	Thu May 18 15:20:43 2017 +0000
+++ b/m24sr/M24SR.cpp	Wed Jul 12 14:15:02 2017 +0000
@@ -58,8 +58,8 @@
 /**
  * default password, also used to enable super user mode through 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 };
+const uint8_tM24SR::DEFAULT_PASSWORD[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
 /** @addtogroup M24SR_Driver
  * @{
@@ -80,7 +80,7 @@
  *  otherwise return the error status*/
 #define errchk(fCall) {\
 	const int status = (int) (fCall); \
-	if((status!=M24SR_SUCCESS)){ \
+	if((status!=M24SR_SUCCESS)) { \
 		return (M24SR::StatusTypeDef)status; \
 	}\
 }
@@ -94,8 +94,7 @@
  static uint16_t M24SR_UpdateCrc(uint8_t ch, uint16_t *lpwCrc) {
 	ch = (ch ^ (uint8_t) ((*lpwCrc) & 0x00FF));
 	ch = (ch ^ (ch << 4));
-	*lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t) ch << 8) ^ ((uint16_t) ch << 3)
-			^ ((uint16_t) ch >> 4);
+	*lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t) ch << 8) ^ ((uint16_t) ch << 3) ^ ((uint16_t) ch >> 4);
 
 	return (*lpwCrc);
 }
@@ -125,12 +124,13 @@
  * @retval 	Status (SW1&SW2)  	:   CRC16 residue is correct	
  * @retval 	M24SR_ERROR_CRC  	:  CRC16 residue is false
  */
- static M24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
+ staticM24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
 	uint16_t ResCRC = 0x0000;
 	M24SR::StatusTypeDef status;
 	/* check the CRC16 Residue */
-	if (Length != 0)
+	if (Length != 0) {
 		ResCRC = M24SR_ComputeCrc(DataIn, Length);
+	}
 
 	if (ResCRC == 0x0000) {
 		/* Good CRC, but error status from M24SR */
@@ -141,14 +141,17 @@
 		ResCRC = M24SR_ComputeCrc(DataIn, 5);
 		if (ResCRC != 0x0000) {
 			/* Bad CRC */
-			return M24SR::M24SR_IO_ERROR_CRC;
+			returnM24SR::M24SR_IO_ERROR_CRC;
 		} else {
 			/* Good CRC, but error status from M24SR */
 			status= (M24SR::StatusTypeDef) (((DataIn[1] << 8) & 0xFF00)
 					| (DataIn[2] & 0x00FF));
 		}
 	}
-	if(status==NFC_COMMAND_SUCCESS) status = M24SR::M24SR_SUCCESS;
+	if (status==NFC_COMMAND_SUCCESS) {
+		status =M24SR::M24SR_SUCCESS;
+	}
+
 	return status;
 }
 
@@ -159,8 +162,7 @@
  * @param	 	NbByte : number of bytes of the command
  * @param	 	pCommand : pointer to the command created
  */
- static void M24SR_BuildIBlockCommand(uint16_t CommandStructure, C_APDU *Command,
-		uint8_t uDIDbyte, uint16_t *NbByte, uint8_t *pCommand) {
+static void M24SR_BuildIBlockCommand(uint16_t CommandStructure, C_APDU *Command, uint8_t uDIDbyte, uint16_t *NbByte, uint8_t *pCommand) {
 	uint16_t uCRC16;
 	static uint8_t BlockNumber = 0x01;
 
@@ -228,17 +230,16 @@
  * @retval 	M24SR_SUCCESS  :  the data is a S-Block
  * @retval 	NFC_ERROR  	:  the data is not a S-Block
  */
- static M24SR::StatusTypeDef IsSBlock(uint8_t *pBuffer) {
+ staticM24SR::StatusTypeDef IsSBlock(uint8_t *pBuffer) {
 
 	if ((pBuffer[M24SR_OFFSET_PCB] & M24SR_MASK_BLOCK) == M24SR_MASK_SBLOCK) {
-		return M24SR::M24SR_SUCCESS;
+		returnM24SR::M24SR_SUCCESS;
 	} else {
-		return M24SR::M24SR_ERROR;
+		returnM24SR::M24SR_ERROR;
 	}
 
 }
 
-
 M24SR::M24SR(const uint8_t address, I2C &I2C,gpoEventCallback eventCallback, const PinName& GPOPinName,
 		const PinName& RFDISPinName) :
 		who_am_i(0),
@@ -258,8 +259,9 @@
 		//mNDefTagUtil(NULL){
 	memset(uM24SRbuffer, 0, 0xFF * sizeof(int8_t));
 	uDIDbyte = 0;
-	if(RFDisablePin.is_connected()!=0)
+	if (RFDisablePin.is_connected()!=0) {
 		RFDisablePin = 0;
+	}
 	if(GPOPin.is_connected()!=0){
 		if(eventCallback!=NULL)
 			mGpoEventInterrupt.fall(eventCallback);
@@ -277,7 +279,7 @@
  * @param	FWTbyte : FWT value
  * @return M24SR_SUCCESS if no errors
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
+M24SR::StatusTypeDefM24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
 	uint8_t pBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
 	uint8_t NthByte = 0;
@@ -294,19 +296,19 @@
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NthByte, pBuffer);
-	if(status != M24SR_SUCCESS)
+	if (status != M24SR_SUCCESS) {
 		return status;
+	}
 
 	mLastCommandSend=UPDATE;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS)
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveUpdateBinary();
-		else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_updated_binary(this,status,mLastCommandData.offset,
-					mLastCommandData.data,mLastCommandData.length);
+			getCallback()->on_updated_binary(this,status,mLastCommandData.offset, mLastCommandData.data,mLastCommandData.length);
 			return status;
 		}//if-else
 	}//if
@@ -318,28 +320,30 @@
  * @brief  This function initialize the M24SR device
  * @retval None
  */
- M24SR::StatusTypeDef M24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
+M24SR::StatusTypeDefM24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
 	(void) notUsed;
 	//force to open a i2c session
 	StatusTypeDef status = M24SR_ForceSession();
-	if(status!= M24SR_SUCCESS)
+	if(status!= M24SR_SUCCESS) {
 		return status;
+	}
 	//leave the gpo always up
-	if(GPOPin.is_connected()!=0){
+	if(GPOPin.is_connected()!=0) {
 		status = M24SR_ManageI2CGPO(DEFAULT_GPO_STATUS);
 		if(status!= M24SR_SUCCESS)
 			return status;
 	}
-	if(RFDisablePin.is_connected()!=0){
+	if(RFDisablePin.is_connected()!=0) {
 		status = M24SR_ManageRFGPO(DEFAULT_GPO_STATUS);
 		if(status!= M24SR_SUCCESS)
 			return status;
 	}
 	//close the session
 	status = M24SR_Deselect();
-	if(status!= M24SR_SUCCESS)
+	if (status!= M24SR_SUCCESS) {
 		return status;
-	if(GPOPin.is_connected()!=0){
+	}
+	if(GPOPin.is_connected()!=0) {
 		mGpoEventInterrupt.enable_irq();
 	}
 	return M24SR_SUCCESS;
@@ -351,11 +355,11 @@
  * @param  None
  * @return M24SR_SUCCESS if no errors
  */
- M24SR::StatusTypeDef M24SR::M24SR_ForceSession(void) {
+M24SR::StatusTypeDefM24SR::M24SR_ForceSession(void) {
 	uint8_t commandBuffer[] = M24SR_KILLSESSION_COMMAND;
 	M24SR::StatusTypeDef status;
 	status = M24SR_IO_SendI2Ccommand(sizeof(commandBuffer), commandBuffer);
-	if(status!=M24SR_SUCCESS){
+	if(status!=M24SR_SUCCESS) {
 		mCallback->on_session_open(this,status);
 		return status;
 	}
@@ -374,22 +378,22 @@
  * @brief  This function sends the Deselect command (S-Block format)
  * @return M24SR_SUCCESS if no errors
  */
- M24SR::StatusTypeDef M24SR::M24SR_Deselect(void) {
+M24SR::StatusTypeDefM24SR::M24SR_Deselect(void) {
 	uint8_t pBuffer[] = M24SR_DESELECTREQUEST_COMMAND;
 	M24SR::StatusTypeDef status;
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(sizeof(pBuffer), pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if(status!=M24SR_SUCCESS) {
 		getCallback()->on_deselect(this,status);
 	}
 
 	mLastCommandSend=DESELECT;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS)
+		if(status == M24SR_SUCCESS) {
 			return M24SR_ReceiveDeselect();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_selected_application(this,status);
 			return status;
@@ -400,7 +404,7 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveDeselect(void){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveDeselect(void) {
 	uint8_t pBuffer[4];
 	M24SR::StatusTypeDef status;
 	status = M24SR_IO_ReceiveI2Cresponse(sizeof(pBuffer), pBuffer);
@@ -408,19 +412,17 @@
 	return status;
 }
 
-
-
 /**
  * @brief  This function sends the GetSession command to the M24SR device
  * @retval M24SR_SUCCESS the function is successful.
  * @retval Status (SW1&SW2) if operation does not complete.
  */
- M24SR::StatusTypeDef M24SR::M24SR_GetSession(void) {
+M24SR::StatusTypeDefM24SR::M24SR_GetSession(void) {
 	uint8_t commandBuffer[] = M24SR_OPENSESSION_COMMAND;
 
 	M24SR::StatusTypeDef status;
 	status = M24SR_IO_SendI2Ccommand(sizeof(commandBuffer), commandBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_session_open(this,status);
 		return status;
 	}
@@ -438,7 +440,7 @@
  * @brief  This function sends the SelectApplication command
  * @return M24SR_SUCCESS if no errors
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendSelectApplication(void) {
+M24SR::StatusTypeDefM24SR::M24SR_SendSelectApplication(void) {
 
 	C_APDU command;
 	M24SR::StatusTypeDef status;
@@ -460,23 +462,22 @@
 	/* copy the number of byte to read */
 	command.Body.LE = uLe;
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_SELECTAPPLICATION, &command,
-			uDIDbyte, &NbByte, pBuffer);
+	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_SELECTAPPLICATION, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
+	if (status != M24SR_SUCCESS) {
 		getCallback()->on_selected_application(this,status);
 		return status;
 	}
 
 	mLastCommandSend=SELECT_APPLICATION;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS)
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveSelectApplication();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_selected_application(this,status);
 			return status;
@@ -486,27 +487,24 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectApplication(void) {
-
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectApplication(void) {
 	uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
 
 	mLastCommandSend = NONE;
 
 	status = M24SR_IO_ReceiveI2Cresponse(sizeof(pDataIn), pDataIn);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_application(this,status);
 		return status;
 	}//else
-	status= M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
+	status = M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
 	getCallback()->on_selected_application(this,status);
+
 	return status;
-
 }
 
-
-
-M24SR::StatusTypeDef M24SR::M24SR_ReadID(uint8_t *nfc_id) {
+M24SR::StatusTypeDefM24SR::M24SR_ReadID(uint8_t *nfc_id) {
 	if (!nfc_id) {
 		return M24SR_ERROR;
 	}
@@ -525,7 +523,7 @@
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  * @retval Status (SW1&SW2)   if operation does not complete for another reason.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendSelectCCfile(void) {
+M24SR::StatusTypeDefM24SR::M24SR_SendSelectCCfile(void) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -543,24 +541,22 @@
 	command.Body.LC = sizeof(pDataOut);
 	command.Body.pData = pDataOut;
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTCCFILE, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTCCFILE, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if(status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_CC_file(this,status);
 		return status;
 	}//else
 
-
 	mLastCommandSend=SELECT_CC_FILE;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC){
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS)
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveSelectCCfile();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_selected_CC_file(this,status);
 			return status;
@@ -570,7 +566,7 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectCCfile(void){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectCCfile(void){
 
 	uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
@@ -578,14 +574,14 @@
 	mLastCommandSend = NONE;
 
 	status = M24SR_IO_ReceiveI2Cresponse(sizeof(pDataIn), pDataIn);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_CC_file(this,status);
 		return status;
 	}//else
-	status= M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
+	status = M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
 	getCallback()->on_selected_CC_file(this,status);
+
 	return status;
-
 }
 
 /**
@@ -593,7 +589,7 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendSelectSystemfile(void) {
+M24SR::StatusTypeDefM24SR::M24SR_SendSelectSystemfile(void) {
 	C_APDU command;
 
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -611,23 +607,22 @@
 	command.Body.LC = sizeof(pDataOut);
 	command.Body.pData = pDataOut;
 	/* build the I²C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTCCFILE, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTCCFILE, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_system_file(this,status);
 		return status;
 	}//else
 
 	mLastCommandSend=SELECT_SYSTEM_FILE;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS)
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveSelectSystemfile();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_selected_system_file(this,status);
 			return status;
@@ -637,22 +632,21 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectSystemfile(){
-
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectSystemfile() {
 	uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
 
 	mLastCommandSend = NONE;
 
 	status = M24SR_IO_ReceiveI2Cresponse(sizeof(pDataIn), pDataIn);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_system_file(this,status);
 		return status;
 	}//else
-	status= M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
+	status = M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
 	getCallback()->on_selected_system_file(this,status);
+
 	return status;
-
 }
 
 /**
@@ -660,7 +654,7 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
+M24SR::StatusTypeDefM24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -678,22 +672,19 @@
 	command.Body.pData = pDataOut;
 	/* copy the offset */
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTNDEFFILE, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTNDEFFILE, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
-
-	}
+	if (status!=M24SR_SUCCESS) {}
 
 	mLastCommandSend=SELECT_NDEF_FILE;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS)
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveSelectNDEFfile();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_selected_NDEF_file(this,status);
 			return status;
@@ -704,7 +695,7 @@
 
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectNDEFfile(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectNDEFfile(){
 
 	uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
@@ -712,14 +703,14 @@
 	mLastCommandSend = NONE;
 
 	status = M24SR_IO_ReceiveI2Cresponse(sizeof(pDataIn), pDataIn);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_selected_NDEF_file(this,status);
 		return status;
 	}//else
 	status= M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
 	getCallback()->on_selected_NDEF_file(this,status);
+
 	return status;
-
 }
 
 /**
@@ -730,11 +721,11 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendReadBinary(uint16_t Offset, uint8_t NbByteToRead,
-		uint8_t *pBufferRead) {
+M24SR::StatusTypeDefM24SR::M24SR_SendReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) {
 	//clamp the buffer to the max size
-	if(NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT)
+	if (NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT) {
 		NbByteToRead=M24SR_MAX_BYTE_OPERATION_LENGHT;
+	}
 
 	C_APDU command;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -750,11 +741,10 @@
 	/* copy the number of byte to read */
 	command.Body.LE = NbByteToRead;
 
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_READBINARY, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_READBINARY, &command, uDIDbyte, &NbByte, pBuffer);
 
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_read_byte(this,status,Offset,pBufferRead,NbByteToRead);
 		return status;
 	}
@@ -764,11 +754,11 @@
 	mLastCommandData.length=NbByteToRead;
 	mLastCommandData.offset=Offset;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveReadBinary();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_read_byte(this,status,Offset,pBufferRead,NbByteToRead);
 			return status;
@@ -778,30 +768,29 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveReadBinary(){
-
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveReadBinary() {
 	M24SR::StatusTypeDef status;
 	const uint16_t length = mLastCommandData.length;
 	const uint16_t offset = mLastCommandData.offset;
 	uint8_t *data = mLastCommandData.data;
 
-	mLastCommandSend=NONE;
+	mLastCommandSend = NONE;
 
 	status = M24SR_IO_ReceiveI2Cresponse (length + M24SR_STATUSRESPONSE_NBBYTE , uM24SRbuffer );
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_read_byte(this,status,offset,data,length);
 		return status;
 	}
 	status = M24SR_IsCorrectCRC16Residue(uM24SRbuffer, length + M24SR_STATUSRESPONSE_NBBYTE);
-	if(status != M24SR_SUCCESS)
+	if (status != M24SR_SUCCESS) {
 		getCallback()->on_read_byte(this,status,offset,data,length);
-	else{
+	} else{
 		/* retrieve the data without SW1 & SW2 as provided as return value of the function */
 		memcpy(mLastCommandData.data, &uM24SRbuffer[1], length);
 		getCallback()->on_read_byte(this,status,offset,data,length);
 	}
+
 	return status;
-
 }
 
 /**
@@ -812,11 +801,11 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendSTReadBinary(uint16_t Offset,
-		uint8_t NbByteToRead, uint8_t *pBufferRead) {
+M24SR::StatusTypeDefM24SR::M24SR_SendSTReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) {
 	//clamp the buffer to the max size
-	if(NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT)
+	if (NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT) {
 		NbByteToRead=M24SR_MAX_BYTE_OPERATION_LENGHT;
+	}
 
 	C_APDU command;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -832,11 +821,10 @@
 	/* copy the number of byte to read */
 	command.Body.LE = NbByteToRead;
 
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_READBINARY, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_READBINARY, &command, uDIDbyte, &NbByte, pBuffer);
 
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_read_byte(this,status,Offset,pBufferRead,NbByteToRead);
 		return status;
 	}
@@ -845,11 +833,11 @@
 	mLastCommandData.data=pBufferRead;
 	mLastCommandData.length=NbByteToRead;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveReadBinary();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_read_byte(this,status,Offset,pBufferRead,NbByteToRead);
 			return status;
@@ -867,11 +855,11 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendUpdateBinary(uint16_t Offset,
-		uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
+M24SR::StatusTypeDefM24SR::M24SR_SendUpdateBinary(uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
 	//clamp the buffer to the max size
-	if(NbByteToWrite>M24SR_MAX_BYTE_OPERATION_LENGHT)
+	if (NbByteToWrite>M24SR_MAX_BYTE_OPERATION_LENGHT) {
 		NbByteToWrite=M24SR_MAX_BYTE_OPERATION_LENGHT;
+	}
 
 	C_APDU command;
 	M24SR::StatusTypeDef status;
@@ -889,11 +877,10 @@
 	command.Body.pData = pDataToWrite;
 	/* copy the File Id */
 	//memcpy(command.Body.pData ,pDataToWrite, NbByteToWrite );
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_UPDATEBINARY, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_UPDATEBINARY, &command, uDIDbyte, &NbByte, pBuffer);
 
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS){
 		getCallback()->on_updated_binary(this,status,Offset,pDataToWrite,NbByteToWrite);
 		return status;
 	}
@@ -903,11 +890,11 @@
 	mLastCommandData.length=NbByteToWrite;
 	mLastCommandData.offset=Offset;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveUpdateBinary();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_updated_binary(this,status,Offset,pDataToWrite,NbByteToWrite);
 			return status;
@@ -917,8 +904,7 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveUpdateBinary() {
-
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveUpdateBinary() {
 	uint8_t respBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 	M24SR::StatusTypeDef status;
 	const uint16_t length = mLastCommandData.length;
@@ -935,8 +921,7 @@
 
 	if (IsSBlock(respBuffer) == M24SR_SUCCESS) {
 		/*check the CRC */
-		status =M24SR_IsCorrectCRC16Residue(respBuffer,
-					M24SR_WATINGTIMEEXTRESPONSE_NBBYTE);
+		status = M24SR_IsCorrectCRC16Residue(respBuffer, M24SR_WATINGTIMEEXTRESPONSE_NBBYTE);
 		// TODO: why if we check ==NFC_Commandsuccess it fail?
 		if (status != M24SR_IO_ERROR_CRC) {
 			/* send the FrameExension response*/
@@ -946,14 +931,13 @@
 			}//status
 		}//if
 	} else { //isSBlock
-		status = M24SR_IsCorrectCRC16Residue(respBuffer,
-				M24SR_STATUSRESPONSE_NBBYTE);
+		status = M24SR_IsCorrectCRC16Residue(respBuffer, M24SR_STATUSRESPONSE_NBBYTE);
 		getCallback()->on_updated_binary(this,status,offset,data,length);
 	}//if else
+
 	return status;
 }//M24SR_ReceiveUpdateBinary
 
-
 /**
  * @brief  This function sends the Verify command
  * @param	uPwdId   PasswordId ( 0x0001 : Read NDEF pwd or 0x0002 : Write NDEF pwd or 0x0003 : I2C pwd)
@@ -962,8 +946,7 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte,
-		const uint8_t *pPwd) {
+M24SR::StatusTypeDefM24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte, const uint8_t *pPwd) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -988,31 +971,28 @@
 		/* copy the password */
 		command.Body.pData = pPwd;
 		/* build the I2C command */
-		M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_VERIFYBINARYWITHPWD, &command,
-				uDIDbyte, &NbByte, pBuffer);
+		M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_VERIFYBINARYWITHPWD, &command, uDIDbyte, &NbByte, pBuffer);
 	} else {
 		command.Body.pData = NULL;
 		/* build the I2C command */
-		M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_VERIFYBINARYWOPWD, &command,
-				uDIDbyte, &NbByte, pBuffer);
+		M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_VERIFYBINARYWOPWD, &command, uDIDbyte, &NbByte, pBuffer);
 	}
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status!=M24SR_SUCCESS){
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_verified(this,status,constToPasswordType(uPwdId),pPwd);
 		return status;
 	}
 	mLastCommandSend=VERIFY;
-
 	mLastCommandData.data=(uint8_t*)pPwd;
 	mLastCommandData.offset=uPwdId;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS)
+		if(status == M24SR_SUCCESS) {
 			return M24SR_ReceiveVerify();
-		else{
+		} else {
 			mLastCommandSend = NONE;
 			getCallback()->on_verified(this,status,constToPasswordType(uPwdId),pPwd);
 			return status;
@@ -1022,7 +1002,7 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveVerify(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveVerify() {
 	M24SR::StatusTypeDef status;
 	uint8_t respBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 	mLastCommandSend=NONE;
@@ -1032,7 +1012,7 @@
 
 	status=M24SR_IO_ReceiveI2Cresponse (sizeof(respBuffer),respBuffer);
 
-	if(status !=M24SR_SUCCESS){
+	if (status !=M24SR_SUCCESS) {
 		getCallback()->on_verified(this,status,type,data);
 		return status;
 	}
@@ -1049,8 +1029,7 @@
  * @retval Status (SW1&SW2) Satus of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId,
-		uint8_t *pPwd) {
+M24SR::StatusTypeDefM24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId, uint8_t *pPwd) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -1058,8 +1037,7 @@
 
 	/*check the parameters */
 	if (uPwdId > 0x0003) {
-		getCallback()->on_change_reference_data(this,M24SR_IO_ERROR_PARAMETER,
-				constToPasswordType(uPwdId), pPwd);
+		getCallback()->on_change_reference_data(this,M24SR_IO_ERROR_PARAMETER, constToPasswordType(uPwdId), pPwd);
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
@@ -1074,14 +1052,12 @@
 	/* copy the password */
 	command.Body.pData = pPwd;
 	/* build the I²C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_CHANGEREFDATA, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_CHANGEREFDATA, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
-		getCallback()->on_change_reference_data(this,status,
-							constToPasswordType(uPwdId), pPwd);
+	if (status != M24SR_SUCCESS) {
+		getCallback()->on_change_reference_data(this,status, constToPasswordType(uPwdId), pPwd);
 		return status;
 	}
 
@@ -1090,14 +1066,13 @@
 	//use the offset filed for store the pwd id;
 	mLastCommandData.offset = (uint8_t)uPwdId;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS){
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveChangeReferenceData();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_change_reference_data(this,status,
-					constToPasswordType(uPwdId), pPwd);
+			getCallback()->on_change_reference_data(this, status, constToPasswordType(uPwdId), pPwd);
 			return status;
 		}//if-else
 	}//if
@@ -1105,7 +1080,7 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveChangeReferenceData(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveChangeReferenceData(){
 	M24SR::StatusTypeDef status;
 	//TODO the size is 3?
 	uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1113,8 +1088,8 @@
 	PasswordType_t type = constToPasswordType(mLastCommandData.offset);
 	uint8_t *data = mLastCommandData.data;
 
-	status =M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
-	if(status!=M24SR_SUCCESS){
+	status = M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_change_reference_data(this,status,type,data);
 		return status;
 	}//else
@@ -1130,8 +1105,7 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendEnableVerificationRequirement(
-		uint16_t uReadOrWrite) {
+M24SR::StatusTypeDefM24SR::M24SR_SendEnableVerificationRequirement(uint16_t uReadOrWrite) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -1139,8 +1113,7 @@
 
 	/*check the parameters */
 	if ((uReadOrWrite != 0x0001) && (uReadOrWrite != 0x0002)) {
-		getCallback()->on_enable_verification_requirement(this,M24SR_IO_ERROR_PARAMETER,
-				constToPasswordType(uReadOrWrite));
+		getCallback()->on_enable_verification_requirement(this,M24SR_IO_ERROR_PARAMETER, constToPasswordType(uReadOrWrite));
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
@@ -1151,14 +1124,12 @@
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command,
-			uDIDbyte, &NbByte, pBuffer);
+	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
-		getCallback()->on_enable_verification_requirement(this,status,
-				constToPasswordType(uReadOrWrite));
+	if (status != M24SR_SUCCESS) {
+		getCallback()->on_enable_verification_requirement(this, status, constToPasswordType(uReadOrWrite));
 		return status;
 	}//if
 
@@ -1166,14 +1137,13 @@
 	//use the offset filed for store the pwd id;
 	mLastCommandData.offset = (uint8_t)uReadOrWrite;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status == M24SR_SUCCESS){
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveEnableVerificationRequirement();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_enable_verification_requirement(this,status,
-							constToPasswordType(uReadOrWrite));
+			getCallback()->on_enable_verification_requirement(this, status, constToPasswordType(uReadOrWrite));
 			return status;
 		}//if-else
 	}//if
@@ -1181,15 +1151,15 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveEnableVerificationRequirement(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveEnableVerificationRequirement(){
 	M24SR::StatusTypeDef status;
 	//TODO the size is 3?
 	uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 
 	const PasswordType_t type = constToPasswordType(mLastCommandData.offset);
 
-	status =M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
-	if(status!=M24SR_SUCCESS){
+	status = M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_enable_verification_requirement(this,status,type);
 		return status;
 	}//else
@@ -1199,15 +1169,13 @@
 	return status;
 }
 
-
 /**
  * @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 I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendDisableVerificationRequirement(
-		uint16_t uReadOrWrite) {
+M24SR::StatusTypeDefM24SR::M24SR_SendDisableVerificationRequirement(uint16_t uReadOrWrite) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -1215,8 +1183,7 @@
 
 	/*check the parameters */
 	if ((uReadOrWrite != 0x0001) && (uReadOrWrite != 0x0002)) {
-		getCallback()->on_disable_verification_requirement(this,M24SR_IO_ERROR_PARAMETER,
-				 constToPasswordType(uReadOrWrite));
+		getCallback()->on_disable_verification_requirement(this,M24SR_IO_ERROR_PARAMETER, constToPasswordType(uReadOrWrite));
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
@@ -1227,14 +1194,12 @@
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
 	/* build the I²C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command,
-			uDIDbyte, &NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
-		getCallback()->on_disable_verification_requirement(this,status,
-				constToPasswordType(uReadOrWrite));
+	if (status != M24SR_SUCCESS) {
+		getCallback()->on_disable_verification_requirement(this, status, constToPasswordType(uReadOrWrite));
 		return status;
 	}
 
@@ -1242,31 +1207,29 @@
 	//use the offset filed for store the pwd id;
 	mLastCommandData.offset = (uint8_t)uReadOrWrite;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status==M24SR_SUCCESS) {
 			return M24SR_ReceiveDisableVerificationRequirement();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_disable_verification_requirement(this,status,
-							constToPasswordType(uReadOrWrite));
+			getCallback()->on_disable_verification_requirement(this, status, constToPasswordType(uReadOrWrite));
 			return status;
 		}//if-else
 	}
 
 	return M24SR_SUCCESS;
-
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveDisableVerificationRequirement(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveDisableVerificationRequirement() {
 	M24SR::StatusTypeDef status;
 	//TODO the size is 3?
 	uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 
 	PasswordType_t type = constToPasswordType(mLastCommandData.offset);
 
-	status =M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
-	if(status!=M24SR_SUCCESS){
+	status = M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_disable_verification_requirement(this,status,type);
 		return status;
 	}//else
@@ -1276,14 +1239,13 @@
 	return status;
 }
 
-
 /**
  * @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 I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDefM24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 
@@ -1292,8 +1254,7 @@
 
 	/*check the parameters */
 	if ((uReadOrWrite != 0x0001) && (uReadOrWrite != 0x0002)) {
-		getCallback()->on_enable_permanent_state(this,M24SR_IO_ERROR_PARAMETER,
-						constToPasswordType(uReadOrWrite));
+		getCallback()->on_enable_permanent_state(this, M24SR_IO_ERROR_PARAMETER, constToPasswordType(uReadOrWrite));
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
@@ -1304,14 +1265,12 @@
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
-		getCallback()->on_enable_permanent_state(this,status,
-				constToPasswordType(uReadOrWrite));
+	if (status != M24SR_SUCCESS) {
+		getCallback()->on_enable_permanent_state(this, status, constToPasswordType(uReadOrWrite));
 		return status;
 	}
 
@@ -1319,14 +1278,13 @@
 	//use the offset filed for store the pwd id;
 	mLastCommandData.offset = (uint8_t)uReadOrWrite;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType==M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveEnablePermanentState();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_enable_permanent_state(this,status,
-							constToPasswordType(uReadOrWrite));
+			getCallback()->on_enable_permanent_state(this, status, constToPasswordType(uReadOrWrite));
 			return status;
 		}//if-else
 	}
@@ -1334,15 +1292,15 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveEnablePermanentState(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveEnablePermanentState() {
 	M24SR::StatusTypeDef status;
 	//TODO the size is 3?
 	uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 
 	PasswordType_t type = constToPasswordType(mLastCommandData.offset);
 
-	status =M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
-	if(status!=M24SR_SUCCESS){
+	status = M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_enable_permanent_state(this,status,type);
 		return status;
 	}//else
@@ -1352,14 +1310,13 @@
 	return status;
 }
 
-
 /**
  * @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 I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDefM24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
 	C_APDU command;
 	M24SR::StatusTypeDef status;
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -1367,8 +1324,7 @@
 
 	/*check the parameters */
 	if ((uReadOrWrite != 0x0001) && (uReadOrWrite != 0x0002)) {
-		getCallback()->on_disable_permanent_state(this,M24SR_IO_ERROR_PARAMETER,
-				constToPasswordType(uReadOrWrite));
+		getCallback()->on_disable_permanent_state(this, M24SR_IO_ERROR_PARAMETER, constToPasswordType(uReadOrWrite));
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
@@ -1379,14 +1335,12 @@
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command,
-			uDIDbyte, &NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
-	if(status != M24SR_SUCCESS){
-		getCallback()->on_enable_permanent_state(this,status,
-				constToPasswordType(uReadOrWrite));
+	if (status != M24SR_SUCCESS) {
+		getCallback()->on_enable_permanent_state(this, status, constToPasswordType(uReadOrWrite));
 		return status;
 	}
 
@@ -1394,14 +1348,13 @@
 	//use the offset filed for store the pwd id;
 	mLastCommandData.offset = (uint8_t)uReadOrWrite;
 
-	if(mCommunicationType==M24SR::SYNC){
+	if (mCommunicationType == M24SR::SYNC) {
 		status = M24SR_IO_PollI2C();
-		if(status==M24SR_SUCCESS){
+		if (status == M24SR_SUCCESS) {
 			return M24SR_ReceiveDisablePermanentState();
-		}else{
+		} else {
 			mLastCommandSend = NONE;
-			getCallback()->on_disable_permanent_state(this,status,
-							constToPasswordType(uReadOrWrite));
+			getCallback()->on_disable_permanent_state(this, status, constToPasswordType(uReadOrWrite));
 			return status;
 		}//if-else
 	}
@@ -1409,15 +1362,15 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ReceiveDisablePermanentState(){
+M24SR::StatusTypeDefM24SR::M24SR_ReceiveDisablePermanentState() {
 	M24SR::StatusTypeDef status;
 	//TODO the size is 3?
 	uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 
 	PasswordType_t type = constToPasswordType(mLastCommandData.offset);
 
-	status =M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
-	if(status!=M24SR_SUCCESS){
+	status = M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , rensponseBuffer );
+	if (status!=M24SR_SUCCESS) {
 		getCallback()->on_disable_permanent_state(this,status,type);
 		return status;
 	}//else
@@ -1433,7 +1386,7 @@
  * @retval Status (SW1&SW2)   Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
+M24SR::StatusTypeDefM24SR::M24SR_SendInterrupt(void) {
 	C_APDU command;
 
 	uint8_t *pBuffer = uM24SRbuffer;
@@ -1442,8 +1395,9 @@
 
 
 	StatusTypeDef status = M24SR_ManageI2CGPO(INTERRUPT);
-	if(status!=M24SR_SUCCESS)
+	if (status!=M24SR_SUCCESS) {
 		return status;
+	}
 
 	/* build the command */
 	command.Header.CLA = C_APDU_CLA_ST;
@@ -1453,15 +1407,13 @@
 	command.Header.P2 = GETLSB(uP1P2);
 	command.Body.LC = 0x00;
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SENDINTERRUPT, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SENDINTERRUPT, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	errchk(M24SR_IO_SendI2Ccommand(NbByte, pBuffer));
 	errchk(M24SR_IO_PollI2C());
 	/* read the response */
-	errchk(
-			M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , pBuffer ));
+	errchk(M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , pBuffer ));
 
 	return M24SR_IsCorrectCRC16Residue(pBuffer, M24SR_STATUSRESPONSE_NBBYTE);
 
@@ -1473,7 +1425,7 @@
  * @retval Status (SW1&SW2) Status of the operation to complete.
  * @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
  */
- M24SR::StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
+M24SR::StatusTypeDefM24SR::M24SR_StateControl(uint8_t uSetOrReset) {
 	C_APDU command;
 	uint8_t *pBuffer = uM24SRbuffer;
 	uint16_t uP1P2 = 0x001F;
@@ -1486,8 +1438,9 @@
 
 
 	StatusTypeDef status = M24SR_ManageI2CGPO(STATE_CONTROL);
-	if(status == M24SR_SUCCESS)
+	if (status == M24SR_SUCCESS) {
 		return status;
+	}
 
 	/* build the command */
 	command.Header.CLA = C_APDU_CLA_ST;
@@ -1501,24 +1454,20 @@
 	//memcpy(command.Body.pData , &uSetOrReset, 0x01 );
 	//command.Body.LE = 0x00 ;
 	/* build the I2C command */
-	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_GPOSTATE, &command, uDIDbyte,
-			&NbByte, pBuffer);
+	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_GPOSTATE, &command, uDIDbyte, &NbByte, pBuffer);
 
 	/* send the request */
 	errchk(M24SR_IO_SendI2Ccommand(NbByte, pBuffer));
 	errchk(M24SR_IO_PollI2C());
 	/* read the response */
-	errchk(
-			M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , pBuffer ));
+	errchk(M24SR_IO_ReceiveI2Cresponse (M24SR_STATUSRESPONSE_NBBYTE , pBuffer ));
 
 	return M24SR_IsCorrectCRC16Residue(pBuffer, M24SR_STATUSRESPONSE_NBBYTE);
-
 }
 
+M24SR::StatusTypeDefM24SR::M24SR_ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
 
-M24SR::StatusTypeDef M24SR::M24SR_ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
-
-	if(GPOPin.is_connected()==0){
+	if (GPOPin.is_connected() == 0) {
 		return M24SR_IO_PIN_NOT_CONNECTED;
 	}
 	if (GPO_I2Cconfig > STATE_CONTROL) {
@@ -1533,9 +1482,9 @@
 	return M24SR_SendSelectApplication();
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_ManageRFGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
+M24SR::StatusTypeDefM24SR::M24SR_ManageRFGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
 
-	if(RFDisablePin.is_connected()==0){
+	if(RFDisablePin.is_connected()==0) {
 		return M24SR_IO_PIN_NOT_CONNECTED;
 	}
 	if (GPO_I2Cconfig > STATE_CONTROL) {
@@ -1550,8 +1499,8 @@
 	return M24SR_SendSelectApplication();
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_RFConfig(uint8_t OnOffChoice) {
-	if(RFDisablePin.is_connected()==0){
+M24SR::StatusTypeDefM24SR::M24SR_RFConfig(uint8_t OnOffChoice) {
+	if (RFDisablePin.is_connected()==0) {
 		return M24SR_IO_PIN_NOT_CONNECTED;
 	}
 	/* Disable RF */
@@ -1563,24 +1512,24 @@
 	return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_IO_SendI2Ccommand(uint8_t NbByte,
-		uint8_t *pBuffer) {
+M24SR::StatusTypeDefM24SR::M24SR_IO_SendI2Ccommand(uint8_t NbByte, uint8_t *pBuffer) {
 	int ret = dev_I2C.write(address, (char*) pBuffer, NbByte);
-	if (ret == 0)
+	if (ret == 0) {
 		return M24SR_SUCCESS;
+	}
 	return M24SR_IO_ERROR_I2CTIMEOUT;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte,
-		uint8_t *pBuffer) {
+M24SR::StatusTypeDefM24SR::M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte, uint8_t *pBuffer) {
 	int ret = dev_I2C.read(address, (char*) pBuffer, NbByte);
-	if (ret == 0)
+	if (ret == 0) {
 		return M24SR_SUCCESS;
+	}
 
 	return M24SR_IO_ERROR_I2CTIMEOUT;
 }
 
-M24SR::StatusTypeDef M24SR::M24SR_IO_PollI2C(void) {
+M24SR::StatusTypeDefM24SR::M24SR_IO_PollI2C(void) {
 
     int status = 1;
     while (status != 0 ) {
@@ -1590,9 +1539,9 @@
     return M24SR_SUCCESS;
 }
 
-M24SR::StatusTypeDef M24SR::manage_event(void){
+M24SR::StatusTypeDefM24SR::manage_event(void){
 
-	switch(mLastCommandSend){
+	switch(mLastCommandSend) {
 		case SELECT_APPLICATION:
 			return M24SR_ReceiveSelectApplication();
 		case SELECT_CC_FILE:
@@ -1619,14 +1568,14 @@
 			return M24SR_ReceiveEnablePermanentState();
 		case DISABLE_PERMANET_STATE:
 			return M24SR_ReceiveDisablePermanentState();
-
 		default:
 			return M24SR_SUCCESS;
 	}//switch
 }//manageInterrupt
 
-NDefLib::NDefNfcTag& M24SR::get_NDef_tag(){
-		return *mNDefTagUtil;
+NDefLib::NDefNfcTag&M24SR::get_NDef_tag(){
+	return *mNDefTagUtil;
 }
 
+
 /******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/
--- a/m24sr/M24SR.h	Thu May 18 15:20:43 2017 +0000
+++ b/m24sr/M24SR.h	Wed Jul 12 14:15:02 2017 +0000
@@ -157,37 +157,37 @@
 			/** called when GetSession or ForceGetSession completes
 			 * @see M24SR#GetSession
 			 * @see M24SR#ForceGetSession */
-			virtual void on_session_open(M24SR *nfc,StatusTypeDef status){
+			virtual void on_session_open(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when Deselect completes
 			 * @see M24SR#Deselect */
-			virtual void on_deselect(M24SR *nfc,StatusTypeDef status){
+			virtual void on_deselect(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when SelectedApplication completes
 			 * @see M24SR#SelectedApplication */
-			virtual void on_selected_application(M24SR *nfc,StatusTypeDef status){
+			virtual void on_selected_application(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when SelectedCCFile completes
 			 * @see M24SR#SelectedCCFile */
-			virtual void on_selected_CC_file(M24SR *nfc,StatusTypeDef status){
+			virtual void on_selected_CC_file(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when SelectedNDEFFile completes
 			 * @see M24SR#SelectedNDEFFile */
-			virtual void on_selected_NDEF_file(M24SR *nfc,StatusTypeDef status){
+			virtual void on_selected_NDEF_file(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when SelectedSystemFile completes
 			 * @see M24SR#SelectedSystemFile */
-			virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status){
+			virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
@@ -195,130 +195,130 @@
 			 * @see M24SR#read_binary
 			 * @see M24SR#STReadBinary */
 			virtual void on_read_byte(M24SR *nfc,StatusTypeDef status,
-					uint16_t offset,uint8_t *readByte, uint16_t nReadByte){
+					uint16_t offset,uint8_t *readByte, uint16_t nReadByte) {
 				(void)nfc; (void)status;(void)offset; (void)readByte; (void)nReadByte;
 			}
 
 			/** called when UpdatedBinary completes
 			 * @see M24SR#UpdatedBinary */
 			virtual void on_updated_binary(M24SR *nfc,StatusTypeDef status,uint16_t offset,
-					uint8_t *writeByte,uint16_t nWriteByte){
+					uint8_t *writeByte,uint16_t nWriteByte) {
 				(void)nfc; (void)status; (void)writeByte; (void)nWriteByte; (void)offset;
 			}
 
 			/** called when Verify completes
 			 * @see M24SR#Verify */
 			virtual void on_verified(M24SR *nfc,StatusTypeDef status,PasswordType_t uPwdId,
-					const uint8_t *pwd){
+					const uint8_t *pwd) {
 				(void)nfc; (void)status;(void)uPwdId;(void)pwd;
 			}
 
 			/** called when ManageI2CGPO completes
 			 * @see M24SR#ManageI2CGPO */
-			virtual void on_manage_I2C_GPO(M24SR *nfc,StatusTypeDef status,NFC_GPO_MGMT newStatus){
+			virtual void on_manage_I2C_GPO(M24SR *nfc,StatusTypeDef status,NFC_GPO_MGMT newStatus) {
 				(void)nfc; (void)status;(void)newStatus;
 			}
 
 			/** called when ManageRFGPO completes
 			 * @see M24SR#ManageRFGPO */
-			virtual void on_manage_RF_GPO(M24SR *nfc,StatusTypeDef status,NFC_GPO_MGMT newStatus){
+			virtual void on_manage_RF_GPO(M24SR *nfc,StatusTypeDef status,NFC_GPO_MGMT newStatus) {
 				(void)nfc; (void)status;(void)newStatus;
 			}
 
 			/** called when ChangeReferenceData completes
 			 * @see M24SR#ChangeReferenceData */
 			virtual void on_change_reference_data(M24SR *nfc ,StatusTypeDef status,PasswordType_t type,
-					uint8_t *data){
+					uint8_t *data) {
 				(void)nfc; (void)status;(void)type;(void)data;
 			}
 
 			/** called when EnableVerificationRequirement completes
 			 * @see M24SR#EnableVerificationRequirement */
-			virtual void on_enable_verification_requirement(M24SR *nfc ,StatusTypeDef status,PasswordType_t type){
+			virtual void on_enable_verification_requirement(M24SR *nfc ,StatusTypeDef status,PasswordType_t type) {
 				(void)nfc; (void)status;(void)type;
 			}
 
 			/** called when disable_verification_requirement completes
 			 * @see M24SR#disable_verification_requirement */
-			virtual void on_disable_verification_requirement(M24SR *nfc , StatusTypeDef status,PasswordType_t type){
+			virtual void on_disable_verification_requirement(M24SR *nfc , StatusTypeDef status,PasswordType_t type) {
 				(void)nfc; (void)status;(void)type;
 			}
 
 			/** called when EnablePermanentState completes
 			 * @see M24SR#EnablePermanentState */
-			virtual void on_enable_permanent_state(M24SR *nfc, StatusTypeDef status, PasswordType_t type){
+			virtual void on_enable_permanent_state(M24SR *nfc, StatusTypeDef status, PasswordType_t type) {
 				(void)nfc; (void)status;(void)type;
 			}
 
 			/** called when DisablePermanentState completes
 			 * @see M24SR#DisablePermanentState */
-			virtual void on_disable_permanent_state(M24SR *nfc, StatusTypeDef status, PasswordType_t type){
+			virtual void on_disable_permanent_state(M24SR *nfc, StatusTypeDef status, PasswordType_t type) {
 				(void)nfc; (void)status;(void)type;
 			}
 
 			/** called when ReadId completes
 			 * @see M24SR#ReadId */
-			virtual void on_read_id(M24SR *nfc, StatusTypeDef status, uint8_t *id){
+			virtual void on_read_id(M24SR *nfc, StatusTypeDef status, uint8_t *id) {
 						(void)nfc; (void)status;(void)id;
 			}
 
 			/** called when EnableReadPassword completes
 			 * @see M24SR#EnableReadPassword */
-			virtual void on_enable_read_password(M24SR *nfc, StatusTypeDef status,const uint8_t *newPwd){
+			virtual void on_enable_read_password(M24SR *nfc, StatusTypeDef status,const uint8_t *newPwd) {
 				(void)nfc; (void)status;(void)newPwd;
 			}
 
 			/** called when EnableWritePassword completes
 			 * @see M24SR#EnableWritePassword */
-			virtual void on_enable_write_password(M24SR *nfc, StatusTypeDef status,const uint8_t *newPwd){
+			virtual void on_enable_write_password(M24SR *nfc, StatusTypeDef status,const uint8_t *newPwd) {
 				(void)nfc; (void)status;(void)newPwd;
 			}
 
 			/** called when DisableReadPassword completes
 			 * @see M24SR#DisableReadPassword */
-			virtual void on_disable_read_password(M24SR *nfc, StatusTypeDef status){
+			virtual void on_disable_read_password(M24SR *nfc, StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when DisableWritePassword completes
 			 * @see M24SR#DisableWritePassword */
-			virtual void on_disable_write_password(M24SR *nfc, StatusTypeDef status){
+			virtual void on_disable_write_password(M24SR *nfc, StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when DisableAllPassword completes
 			 * @see M24SR#DisableAllPassword */
-			virtual void on_disable_all_password(M24SR *nfc, StatusTypeDef status){
+			virtual void on_disable_all_password(M24SR *nfc, StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 
 			/** called when EnableReadOnly completes
 			 * @see M24SR#EnableReadOnly */
-			virtual void on_enable_read_only(M24SR *nfc,StatusTypeDef status){
+			virtual void on_enable_read_only(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when EnableWriteOnly completes
 			 * @see M24SR#EnableWriteOnly */
-			virtual void on_enable_write_only(M24SR *nfc,StatusTypeDef status){
+			virtual void on_enable_write_only(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 
 			/** called when DisableReadOnly completes
 			 * @see M24SR#DisableReadOnly */
-			virtual void on_disable_read_only(M24SR *nfc,StatusTypeDef status){
+			virtual void on_disable_read_only(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
 			/** called when DisableWriteOnly completes
 			 * @see M24SR#DisableWriteOnly */
-			virtual void on_disable_write_only(M24SR *nfc,StatusTypeDef status){
+			virtual void on_disable_write_only(M24SR *nfc,StatusTypeDef status) {
 				(void)nfc; (void)status;
 			}
 
-			virtual ~Callbacks(){};
+			virtual ~Callbacks() {};
 		};
 
 	/*** Constructor and Destructor Methods ***/
@@ -533,11 +533,12 @@
 	 * Change the function to call when a command ends.
 	 * @param commandCallback Object containing the callback, if NULL it will use empty callback
 	 */
-	void set_callback(Callbacks *commandCallback){
-		if(commandCallback!=NULL)
+	void set_callback(Callbacks *commandCallback) {
+		if (commandCallback!=NULL) {
 			mCallback = commandCallback;
-		else
+		} else {
 			mCallback = &defaultCallback;
+		}
 	}
 
 
@@ -551,8 +552,7 @@
 	 * @return return M24SR_SUCCESS if no errors
 	 * @par The password must have a length of 16 chars.
 	 */
-	StatusTypeDef enable_read_password(const uint8_t* pCurrentWritePassword,
-				const uint8_t* pNewPassword) {
+	StatusTypeDef enable_read_password(const uint8_t* pCurrentWritePassword, const uint8_t* pNewPassword) {
 
 		//enable the callback for change the gpo
 		mComponentCallback = &mChangePasswordRequestStatusCallback;
@@ -581,8 +581,7 @@
 	 * @return return M24SR_SUCCESS if no errors
 	 * @par The password must have a length of 16 chars.
 	 */
-	StatusTypeDef enable_write_password(const uint8_t* pCurrentWritePassword,
-				uint8_t* pNewPassword) {
+	StatusTypeDef enable_write_password(const uint8_t* pCurrentWritePassword, uint8_t* pNewPassword) {
 		//enable the callback for change the gpo
 		mComponentCallback = &mChangePasswordRequestStatusCallback;
 		mChangePasswordRequestStatusCallback.set_task(WritePwd,pNewPassword);
@@ -609,7 +608,7 @@
 	 * @return  return M24SR_SUCCESS if no errors
 	 * @par The password must have a length of 16 chars.
 	 */
-	StatusTypeDef disable_all_password(const uint8_t* pSuperUserPassword){
+	StatusTypeDef disable_all_password(const uint8_t* pSuperUserPassword) {
 		mComponentCallback = &mRemoveAllPasswordCallback;
 		return verify(M24SR::I2CPwd, 0x10, pSuperUserPassword);
 	}
@@ -620,8 +619,7 @@
 	 * @return  return M24SR_SUCCESS if no errors
 	 * @par The password must have a length of 16 chars.
 	 */
-	StatusTypeDef enable_read_only(const uint8_t* pCurrentWritePassword){
-
+	StatusTypeDef enable_read_only(const uint8_t* pCurrentWritePassword) {
 		mComponentCallback = &mChangeAccessStateCallback;
 		//disable write = read only
 		mChangeAccessStateCallback.change_access_state(ChangeAccessStateCallback::WRITE,false);
@@ -638,6 +636,7 @@
 	StatusTypeDef disable_read_only(const uint8_t* pCurrentWritePassword) {
 		mComponentCallback = &mChangeAccessStateCallback;
 		mChangeAccessStateCallback.change_access_state(ChangeAccessStateCallback::WRITE,true);
+
 		return verify(M24SR::I2CPwd, 0x10,pCurrentWritePassword);
 	}
 
@@ -649,13 +648,11 @@
 	 * @par The password must have a length of 16 chars.
 	 */
 	StatusTypeDef enable_write_only(const uint8_t* pCurrentWritePassword) {
-
 		mComponentCallback = &mChangeAccessStateCallback;
 		//disable read = enable write only
 		mChangeAccessStateCallback.change_access_state(ChangeAccessStateCallback::READ,false);
 
 		return verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-
 	}
 
 	/**
@@ -667,6 +664,7 @@
 	StatusTypeDef disable_write_only(const uint8_t* pCurrentWritePassword) {
 		mComponentCallback = &mChangeAccessStateCallback;
 		mChangeAccessStateCallback.change_access_state(ChangeAccessStateCallback::READ,true);
+
 		return verify(M24SR::I2CPwd, 0x10, pCurrentWritePassword);
 	}
 
@@ -687,8 +685,6 @@
 	StatusTypeDef M24SR_GetSession(void);
 	StatusTypeDef M24SR_ForceSession(void);
 
-
-
 	StatusTypeDef M24SR_Deselect(void);
 	StatusTypeDef M24SR_ReceiveDeselect(void);
 
@@ -759,8 +755,7 @@
 	 * @param pBuffer Buffer to store the response into.
 	 * @return M24SR_SUCCESS if no errors
 	 */
-	StatusTypeDef M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte,
-			uint8_t *pBuffer);
+	StatusTypeDef M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte, uint8_t *pBuffer);
 
 	/**
 	 * Do an active polling on the I2C bus until the answer is ready.
@@ -773,7 +768,7 @@
 	 * @param[out] pPinState Variable to store the pin state into.
 	 */
 	void M24SR_IO_GPO_ReadPin(uint8_t *pPinState) {
-		*pPinState= GPOPin.read();
+		*pPinState = GPOPin.read();
 	}
 
 	/**
@@ -781,10 +776,12 @@
 	 * @param pPinState Pin state to write.
 	 */
 	void M24SR_IO_RFDIS_WritePin(uint8_t PinState) {
-		if (PinState == 0)
+		if (PinState == 0) {
 			RFDisablePin = 0;
-		else
+		}
+		else {
 			RFDisablePin = 1;
+		}
 	}
 
 	/*** Component's Instance Variables ***/
@@ -899,9 +896,10 @@
 	 * get the callback object to use
 	 * @return callback object to use
 	 */
-	Callbacks * getCallback(){
-		if(mComponentCallback!=NULL)
+	Callbacks * getCallback() {
+		if (mComponentCallback != NULL) {
 			return mComponentCallback;
+		}
 		return mCallback;
 	}//getCallback
 
@@ -925,7 +923,7 @@
 	 *   <li> disable_verification_requirement </li>
 	 * </ul>
 	 */
-	class ChangePasswordRequestStatusCallback : public Callbacks{
+	class ChangePasswordRequestStatusCallback : public Callbacks {
 
 		public:
 
@@ -933,45 +931,48 @@
 			 * Build the chain of callbacks.
 			 */
 			ChangePasswordRequestStatusCallback():
-				mNewPwd(NULL),mType(I2CPwd),mEnable(false){}
+				mNewPwd(NULL), mType(I2CPwd),mEnable(false) {}
 
 			/**
 			 * Set the password to enable/disable.
 			 * @param type Type of password to enable/disable.
 			 * @param newPwd Array of 16bytes with the new password, if null the request will be disabled.
 			 */
-			void set_task(PasswordType_t type, const uint8_t *newPwd){
+			void set_task(PasswordType_t type, const uint8_t *newPwd) {
 				mNewPwd=newPwd;
 				mType=type;
 				mEnable=newPwd!=NULL;
 			}//setTask
 
 			virtual void on_verified(M24SR *nfc, StatusTypeDef status,PasswordType_t ,
-					const uint8_t *){
-				if(status!=M24SR_SUCCESS)
+					const uint8_t *) {
+				if (status!=M24SR_SUCCESS) {
 					return onFinishCommand(nfc,status);
-				if(mEnable)
+				}
+				if (mEnable) {
 					nfc->change_reference_data(mType,mNewPwd);
-				else
+				} else {
 					nfc->disable_verification_requirement(mType);
+				}
 			}
 
 			virtual void on_disable_verification_requirement(M24SR *nfc,
-					StatusTypeDef status, PasswordType_t ){
+					StatusTypeDef status, PasswordType_t ) {
 				onFinishCommand(nfc,status);
 			}
 
 			virtual void on_change_reference_data(M24SR *nfc, StatusTypeDef status,
 					PasswordType_t type,
-					uint8_t *){
-				if(status==M24SR_SUCCESS)
+					uint8_t *) {
+				if (status==M24SR_SUCCESS) {
 					nfc->enable_permanent_state(type);
-				else
+				} else {
 					onFinishCommand(nfc,status);
+				}
 			}
 
 			virtual void on_enable_permanent_state(M24SR *nfc, StatusTypeDef status,
-					PasswordType_t ){
+					PasswordType_t ) {
 				onFinishCommand(nfc,status);
 			}
 
@@ -983,19 +984,21 @@
 			 * @param nfc Object triggering the command.
 			 * @param status Command status.
 			 */
-			void onFinishCommand(M24SR *nfc,StatusTypeDef status){
+			void onFinishCommand(M24SR *nfc,StatusTypeDef status) {
 				nfc->mComponentCallback=NULL;
 
-				if(mEnable){
-					if(mType==ReadPwd){
+				if (mEnable) {
+					if (mType==ReadPwd) {
 						nfc->getCallback()->on_enable_read_password(nfc,status,mNewPwd);
-					}else
+					} else {
 						nfc->getCallback()->on_enable_write_password(nfc,status,mNewPwd);
-				}else{
-					if(mType==ReadPwd){
+					}
+				} else {
+					if (mType==ReadPwd) {
 						nfc->getCallback()->on_disable_read_password(nfc,status);
-					}else
+					} else {
 						nfc->getCallback()->on_disable_write_password(nfc,status);
+					}
 				}//if-else enable
 			}//onFinish
 
@@ -1003,209 +1006,217 @@
 			PasswordType_t mType;
 			bool mEnable;
 
-		};
-
-
-		/**
-		 * Object containing the callback chain needed to change the password request
-		 */
-		ChangePasswordRequestStatusCallback mChangePasswordRequestStatusCallback;
-		friend class ChangePasswordRequestStatusCallback;
+	};
 
-		/**
-		 * This class permits to disable all the password requests to read/write into the tag
-		 * This class is equivalent to calling the methods:
-		 * <ul>
-		 *   <li> Verify(i2c) </li>
-		 *   <li> DisablePermanentState(Read) </li>
-		 *   <li> DisablePermanentState(write) </li>
-		 *   <li> disable_verification_requirement(Read) </li>
-		 *   <li> disable_verification_requirement(write) </li>
-		 *   <li> ChangeReferenceData(Read) </li>
-		 *   <li> ChangeReferenceData(write) </li>
-		 * </ul>
-		 */
-		class RemoveAllPasswordCallback : public Callbacks{
-
-			/**
-			 * Store the default password used for open a super user session
-			 * it will be set as default read/write password
-			 */
-			const uint8_t *mI2CPwd;
-
-			public:
-
-				/**
-				 * Build the chain of callbacks.
-				 */
-				RemoveAllPasswordCallback():mI2CPwd(NULL){}
-
-				virtual void on_verified(M24SR *nfc,StatusTypeDef status,
-						PasswordType_t,const uint8_t* data){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
-					mI2CPwd = data;
-					nfc->disable_permanent_state(ReadPwd);
-				}
+	/**
+	 * Object containing the callback chain needed to change the password request
+	 */
+	ChangePasswordRequestStatusCallback mChangePasswordRequestStatusCallback;
+	friend class ChangePasswordRequestStatusCallback;
 
-				virtual void on_disable_permanent_state(M24SR *nfc , StatusTypeDef status,
-						PasswordType_t type){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
-					if(type==ReadPwd)
-						nfc->disable_permanent_state(WritePwd);
-					else
-						nfc->disable_verification_requirement(ReadPwd);
-				}
-
-				virtual void on_disable_verification_requirement(M24SR *nfc ,
-						StatusTypeDef status,PasswordType_t type){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
-					if(type==ReadPwd)
-						nfc->disable_verification_requirement(WritePwd);
-					else
-						nfc->change_reference_data(ReadPwd,mI2CPwd);
-				}
-
-				virtual void on_change_reference_data(M24SR *nfc ,StatusTypeDef status,PasswordType_t type,
-						uint8_t *data){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
-					if(type==ReadPwd)
-						nfc->change_reference_data(WritePwd,data);
-					else
-						onFinishCommand(nfc,status);
-				}
-
-			private:
-
-				/**
-				 * Remove the private callback and call the onDisableAllPassword callback.
-				 * @param nfc Object triggering the command.
-				 * @param status Command status.
-				 */
-				void onFinishCommand(M24SR *nfc,StatusTypeDef status){
-					nfc->mComponentCallback=NULL;
-					mI2CPwd=NULL;
-					nfc->getCallback()->on_disable_all_password(nfc,status);
-				}//onFinish
-
-		};
-
-
-		/**
-		 * Object containing the callback chain needed to remove the password request
-		 */
-		RemoveAllPasswordCallback mRemoveAllPasswordCallback;
-		friend class RemoveAllPasswordCallback;
+	/**
+	 * This class permits to disable all the password requests to read/write into the tag
+	 * This class is equivalent to calling the methods:
+	 * <ul>
+	 *   <li> Verify(i2c) </li>
+	 *   <li> DisablePermanentState(Read) </li>
+	 *   <li> DisablePermanentState(write) </li>
+	 *   <li> disable_verification_requirement(Read) </li>
+	 *   <li> disable_verification_requirement(write) </li>
+	 *   <li> ChangeReferenceData(Read) </li>
+	 *   <li> ChangeReferenceData(write) </li>
+	 * </ul>
+	 */
+	class RemoveAllPasswordCallback : public Callbacks{
 
 		/**
-		 * This class permits to set the tag as read/write only
-		 * This class is equivalent to calling the methods:
-		 * <ul>
-		 *   <li> Verify(i2c) </li>
-		 *   <li> EnablePermanentState(Read/write) </li>
-		 * </ul>
-		 * or:
-		 * <ul>
-		 *   <li> Verify(i2c) </li>
-		 *   <li> DisablePermanentState</li>
-		 *   <li> disable_verification_requirement(Read/write) </li>
-		 * </ul>
+		 * Store the default password used for open a super user session
+		 * it will be set as default read/write password
 		 */
-		class ChangeAccessStateCallback : public Callbacks{
+		const uint8_t *mI2CPwd;
+
+		public:
+
+			/**
+			 * Build the chain of callbacks.
+			 */
+			RemoveAllPasswordCallback():mI2CPwd(NULL) {}
 
-			public:
+			virtual void on_verified(M24SR *nfc,StatusTypeDef status,
+					PasswordType_t,const uint8_t* data) {
+				if (status!=M24SR_SUCCESS) {
+					return onFinishCommand(nfc,status);
+				}
+				mI2CPwd = data;
+				nfc->disable_permanent_state(ReadPwd);
+			}
 
-				typedef enum{
-					WRITE,
-					READ
-				}AccessType_t;
+			virtual void on_disable_permanent_state(M24SR *nfc , StatusTypeDef status,
+					PasswordType_t type) {
+				if (status!=M24SR_SUCCESS) {
+					return onFinishCommand(nfc,status);
+				}
+				if (type==ReadPwd) {
+					nfc->disable_permanent_state(WritePwd);
+				} else {
+					nfc->disable_verification_requirement(ReadPwd);
+				}
+			}
+
+			virtual void on_disable_verification_requirement(M24SR *nfc ,
+					StatusTypeDef status,PasswordType_t type) {
+				if (status!=M24SR_SUCCESS) {
+					return onFinishCommand(nfc,status);
+				}
+				if (type==ReadPwd) {
+					nfc->disable_verification_requirement(WritePwd);
+				} else {
+					nfc->change_reference_data(ReadPwd,mI2CPwd);
+				}
+			}
+
+			virtual void on_change_reference_data(M24SR *nfc ,StatusTypeDef status,PasswordType_t type,
+					uint8_t *data) {
+				if (status!=M24SR_SUCCESS) {
+					return onFinishCommand(nfc,status);
+				}
+				if (type==ReadPwd) {
+					nfc->change_reference_data(WritePwd,data);
+				} else {
+					onFinishCommand(nfc,status);
+				}
+			}
+
+		private:
 
-				/**
-				 * Build the chain of callbacks.
-				 */
-				ChangeAccessStateCallback():mType(WRITE),mEnable(false){}
+			/**
+			 * Remove the private callback and call the onDisableAllPassword callback.
+			 * @param nfc Object triggering the command.
+			 * @param status Command status.
+			 */
+			void onFinishCommand(M24SR *nfc,StatusTypeDef status) {
+				nfc->mComponentCallback=NULL;
+				mI2CPwd=NULL;
+				nfc->getCallback()->on_disable_all_password(nfc,status);
+			}//onFinish
+
+	};
+
+
+	/**
+	 * Object containing the callback chain needed to remove the password request
+	 */
+	RemoveAllPasswordCallback mRemoveAllPasswordCallback;
+	friend class RemoveAllPasswordCallback;
 
-				/**
-				 * Set the access to enable/disable an access type.
-				 * @param type Access type.
-				 * @param enable True to enable the state, False to disable it.
-				 */
-				void change_access_state(AccessType_t type,bool enable){
-					mType=type;
-					mEnable=enable;
-				}
+	/**
+	 * This class permits to set the tag as read/write only
+	 * This class is equivalent to calling the methods:
+	 * <ul>
+	 *   <li> Verify(i2c) </li>
+	 *   <li> EnablePermanentState(Read/write) </li>
+	 * </ul>
+	 * or:
+	 * <ul>
+	 *   <li> Verify(i2c) </li>
+	 *   <li> DisablePermanentState</li>
+	 *   <li> disable_verification_requirement(Read/write) </li>
+	 * </ul>
+	 */
+	class ChangeAccessStateCallback : public Callbacks{
+
+		public:
 
-				virtual void on_verified(M24SR *nfc,StatusTypeDef status,
-						PasswordType_t,const uint8_t*){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
+			typedef enum{
+				WRITE,
+				READ
+			}AccessType_t;
+
+			/**
+			 * Build the chain of callbacks.
+			 */
+			ChangeAccessStateCallback():mType(WRITE),mEnable(false) {}
 
-					if(mEnable){
-						nfc->disable_permanent_state(mType==WRITE? WritePwd : ReadPwd);
-					}else
-						nfc->enable_permanent_state(mType==WRITE? WritePwd : ReadPwd);
+			/**
+			 * Set the access to enable/disable an access type.
+			 * @param type Access type.
+			 * @param enable True to enable the state, False to disable it.
+			 */
+			void change_access_state(AccessType_t type,bool enable) {
+				mType=type;
+				mEnable=enable;
+			}
 
+			virtual void on_verified(M24SR *nfc,StatusTypeDef status,
+					PasswordType_t,const uint8_t*) {
+				if (status!=M24SR_SUCCESS){
+					return onFinishCommand(nfc,status);
 				}
 
-				virtual void on_disable_permanent_state(M24SR *nfc, StatusTypeDef status,
-						PasswordType_t type ){
-					if(status!=M24SR_SUCCESS)
-						return onFinishCommand(nfc,status);
-
-					nfc->disable_verification_requirement(type);
+				if (mEnable) {
+					nfc->disable_permanent_state(mType==WRITE? WritePwd : ReadPwd);
+				} else {
+					nfc->enable_permanent_state(mType==WRITE? WritePwd : ReadPwd);
 				}
 
-				virtual void on_disable_verification_requirement(M24SR *nfc , StatusTypeDef status,
-						PasswordType_t ){
-					onFinishCommand(nfc,status);
+			}
+
+			virtual void on_disable_permanent_state(M24SR *nfc, StatusTypeDef status,
+					PasswordType_t type ) {
+				if (status!=M24SR_SUCCESS) {
+					return onFinishCommand(nfc,status);
 				}
 
-				virtual void on_enable_permanent_state(M24SR *nfc ,StatusTypeDef status,PasswordType_t ){
-					onFinishCommand(nfc,status);
-				}
+				nfc->disable_verification_requirement(type);
+			}
+
+			virtual void on_disable_verification_requirement(M24SR *nfc , StatusTypeDef status, PasswordType_t ) {
+				onFinishCommand(nfc,status);
+			}
+
+			virtual void on_enable_permanent_state(M24SR *nfc ,StatusTypeDef status,PasswordType_t ) {
+				onFinishCommand(nfc,status);
+			}
 
 
-			private:
+		private:
 
-				/**
-				 * Remove the private callback and call the user callback.
-				 * @param nfc Object triggering the command.
-				 * @param status Command status.
-				 */
-				void onFinishCommand(M24SR *nfc,StatusTypeDef status){
-					nfc->mComponentCallback=NULL;
-					if(mEnable){
-						if(mType==READ){
-							//enable read = disable write only
-							nfc->getCallback()->on_disable_write_only(nfc,status);
-						}else
-							//enable write = disable read only
-							nfc->getCallback()->on_disable_read_only(nfc,status);
-					}else{
-						if(mType==WRITE){
-							//disable write = enable read only
-							nfc->getCallback()->on_enable_read_only(nfc,status);
-						}else{
-							//
-							nfc->getCallback()->on_enable_write_only(nfc,status);
-						}
-					}//if-else enable
-				}//onFinish
+			/**
+			 * Remove the private callback and call the user callback.
+			 * @param nfc Object triggering the command.
+			 * @param status Command status.
+			 */
+			void onFinishCommand(M24SR *nfc,StatusTypeDef status) {
+				nfc->mComponentCallback=NULL;
+				if (mEnable) {
+					if (mType==READ) {
+						//enable read = disable write only
+						nfc->getCallback()->on_disable_write_only(nfc,status);
+					} else {}
+						//enable write = disable read only
+						nfc->getCallback()->on_disable_read_only(nfc,status);
+					}
+				} else {
+					if (mType==WRITE) {
+						//disable write = enable read only
+						nfc->getCallback()->on_enable_read_only(nfc,status);
+					} else {
+						//
+						nfc->getCallback()->on_enable_write_only(nfc,status);
+					}
+				}//if-else enable
+			}//onFinish
 
-				AccessType_t mType;
-				bool mEnable;
-
-		};
+			AccessType_t mType;
+			bool mEnable;
+	};
 
 
-		/**
-		 * Object containing the callback chain needed to change the access state
-		 */
-		ChangeAccessStateCallback mChangeAccessStateCallback;
-		friend class ChangeAccessStateCallback;
+	/**
+	 * Object containing the callback chain needed to change the access state
+	 */
+	ChangeAccessStateCallback mChangeAccessStateCallback;
+	friend class ChangeAccessStateCallback;
 
 
 	/**
@@ -1228,7 +1239,7 @@
 		 * @param parent Parent component to run the command on.
 		 */
 		ManageGPOCallback(M24SR &parent):mParent(parent),
-				mGpoConfig(HIGH_IMPEDANCE),mReadGpoConfig(0),mI2CGpo(true){}
+				mGpoConfig(HIGH_IMPEDANCE),mReadGpoConfig(0),mI2CGpo(true) {}
 
 
 		/**
@@ -1236,52 +1247,57 @@
 		 * @param i2cGpo true to change the i2c gpo, false for the rf gpo.
 		 * @param newConfig new gpo function.
 		 */
-		void set_new_GPO_config(bool i2cGpo,NFC_GPO_MGMT newConfig){
+		void set_new_GPO_config(bool i2cGpo,NFC_GPO_MGMT newConfig) {
 			mGpoConfig=newConfig;
 			mI2CGpo =i2cGpo;
 		}
 
-		virtual void on_selected_application(M24SR *nfc,StatusTypeDef status){
-			if(status==M24SR_SUCCESS)
+		virtual void on_selected_application(M24SR *nfc,StatusTypeDef status) {
+			if (status==M24SR_SUCCESS) {
 				nfc->select_system_file();
-			else
+			} else {
 				onFinishCommand(nfc,status);
+			}
 		}
 
-		virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status){
-			if(status==M24SR_SUCCESS)
+		virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status) {
+			if (status==M24SR_SUCCESS) {
 				nfc->read_binary(0x0004, 0x01, &mReadGpoConfig);
-			else
+			} else {
 				onFinishCommand(nfc,status);
+			}
 		}
 
 		virtual void on_read_byte(M24SR *nfc,StatusTypeDef status,
-				uint16_t,uint8_t*, uint16_t ){
-			if(status==M24SR_SUCCESS)
+				uint16_t,uint8_t*, uint16_t ) {
+			if (status==M24SR_SUCCESS) {
 				nfc->verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD);
-			else
+			} else {
 				onFinishCommand(nfc,status);
+			}
 		}
 
-		virtual void on_verified(M24SR *nfc,StatusTypeDef status,PasswordType_t, const uint8_t*){
-			if(status!=M24SR_SUCCESS)
+		virtual void on_verified(M24SR *nfc,StatusTypeDef status,PasswordType_t, const uint8_t*) {
+			if (status!=M24SR_SUCCESS) {
 				return onFinishCommand(nfc,status);
+			}
 
-			if(mI2CGpo)
+			if (mI2CGpo) {
 				mReadGpoConfig = (mReadGpoConfig & 0xF0) | (uint8_t)mGpoConfig;
-			else
+			} else {
 				mReadGpoConfig = (mReadGpoConfig & 0x0F) | (((uint8_t)mGpoConfig)<<4);
+			}
 
 			nfc->update_binary(0x0004, 0x01, &mReadGpoConfig);
 		}
 
 		virtual void on_updated_binary(M24SR *nfc,StatusTypeDef status,
-				uint16_t , uint8_t*, uint16_t ){
+				uint16_t , uint8_t*, uint16_t ) {
 
-			if(status==M24SR_SUCCESS){
-				if (mGpoConfig == I2C_ANSWER_READY){
+			if (status==M24SR_SUCCESS) {
+				if (mGpoConfig == I2C_ANSWER_READY) {
 					mParent.mCommunicationType = ASYNC;
-				}else{
+				} else {
 					mParent.mCommunicationType = SYNC;
 				}//if-else
 			}//status
@@ -1295,11 +1311,11 @@
 		 * @param nfc Object where the command was send to.
 		 * @param status Command status.
 		 */
-		void onFinishCommand(M24SR *nfc,StatusTypeDef status){
+		void onFinishCommand(M24SR *nfc,StatusTypeDef status) {
 			mParent.mComponentCallback=NULL;
-			if(mI2CGpo){
+			if (mI2CGpo) {
 				mParent.mCallback->on_manage_I2C_GPO(nfc,status,mGpoConfig);
-			}else{
+			} else {
 				mParent.mCallback->on_manage_RF_GPO(nfc,status,mGpoConfig);
 			}//if-else
 		}//onFinishCommand
@@ -1329,7 +1345,6 @@
 	 */
 	ManageGPOCallback mManageGPOCallback;
 
-
 	/**
 	 * Object with the callback used to read the component ID
 	 * This class is equivalent to calling the methods:
@@ -1339,62 +1354,64 @@
 	 *   <li> read_binary </li>
 	 * </ul>
 	 */
-	class ReadIDCallback : public Callbacks{
+	class ReadIDCallback : public Callbacks {
 
-	public:
+		public:
 
-		/**
-		 * Build the chain of callbacks.
-		 * @param parent object where to send the command to.
-		 */
-		ReadIDCallback(M24SR &parent):mParent(parent),mIdPtr(NULL){}
+			/**
+			 * Build the chain of callbacks.
+			 * @param parent object where to send the command to.
+			 */
+			ReadIDCallback(M24SR &parent):mParent(parent),mIdPtr(NULL) {}
 
-		/**
-		 * Set the variable containing the result
-		 * @param idPtr
-		 */
-		void read_id_on(uint8_t *idPtr){
-			mIdPtr=idPtr;
-		}
+			/**
+			 * Set the variable containing the result
+			 * @param idPtr
+			 */
+			void read_id_on(uint8_t *idPtr) {
+				mIdPtr = idPtr;
+			}
 
-		virtual void on_selected_application(M24SR *nfc,StatusTypeDef status){
-			if(status==M24SR_SUCCESS){
-				nfc->select_system_file();
-			}else
-				onFinishCommand(nfc,status);
+			virtual void on_selected_application(M24SR *nfc,StatusTypeDef status) {
+				if (status==M24SR_SUCCESS) {
+					nfc->select_system_file();
+				} else {
+					onFinishCommand(nfc,status);
+				}
 
-		}
+			}
 
-		virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status){
-			if(status==M24SR_SUCCESS){
-				nfc->read_binary(0x0011, 0x01, mIdPtr);
-			}else
-				onFinishCommand(nfc,status);
-		}
+			virtual void on_selected_system_file(M24SR *nfc,StatusTypeDef status) {
+				if (status==M24SR_SUCCESS) {
+					nfc->read_binary(0x0011, 0x01, mIdPtr);
+				} else {
+					onFinishCommand(nfc,status);
+				}
+			}
 
-		virtual void on_read_byte(M24SR *nfc,StatusTypeDef status,
-			uint16_t ,uint8_t *, uint16_t ){
-			onFinishCommand(nfc,status);
-		}
+			virtual void on_read_byte(M24SR *nfc,StatusTypeDef status,
+				uint16_t ,uint8_t *, uint16_t ) {
+				onFinishCommand(nfc,status);
+			}
 
-	private:
+		private:
 
-		/**
-		 * Remove the private callback and call the user onReadId function.
-		 * @param nfc Object where the command was send.
-		 * @param status Command status.
-		 */
-		void onFinishCommand(M24SR *nfc,StatusTypeDef status){
-			mParent.mComponentCallback=NULL;
-			mParent.getCallback()->on_read_id(nfc,status,mIdPtr);
-		}
+			/**
+			 * Remove the private callback and call the user onReadId function.
+			 * @param nfc Object where the command was send.
+			 * @param status Command status.
+			 */
+			void onFinishCommand(M24SR *nfc,StatusTypeDef status) {
+				mParent.mComponentCallback=NULL;
+				mParent.getCallback()->on_read_id(nfc,status,mIdPtr);
+			}
 
-		M24SR& mParent;
+			M24SR& mParent;
 
-		/**
-		 * pointer to read id
-		 */
-		uint8_t *mIdPtr;
+			/**
+			 * pointer to read id
+			 */
+			uint8_t *mIdPtr;
 	};
 
 
@@ -1408,8 +1425,8 @@
 	 * Convert a generic enum to the value used by the M24SR chip.
 	 * @param type Password type.
 	 * @return equivalent value used inside the m24sr chip */
-	uint16_t passwordTypeToConst(const PasswordType_t &type)const{
-		switch(type){
+	uint16_t passwordTypeToConst(const PasswordType_t &type) const {
+		switch (type) {
 			case ReadPwd:
 				return READ_PWD;
 			case WritePwd:
@@ -1426,7 +1443,7 @@
 	 * @return
 	 */
 	PasswordType_t constToPasswordType(const uint16_t type)const{
-		switch(type){
+		switch(type) {
 			case READ_PWD:
 				return ReadPwd;
 			case WRITE_PWD:
@@ -1440,4 +1457,5 @@
 
 #endif // __M24SR_CLASS_H
 
+
 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/m24sr/NDefNfcTagM24SR.cpp	Thu May 18 15:20:43 2017 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp	Wed Jul 12 14:15:02 2017 +0000
@@ -49,44 +49,40 @@
 ////////////////////////////START  OpenSessionCallBack/////////////////////////
 NDefNfcTagM24SR::OpenSessionCallBack::
 	OpenSessionCallBack(NDefNfcTagM24SR& sender):
-		mSender(sender),mNTrials(OPENSESSION_NTRIALS){}
+		mSender(sender), mNTrials(OPENSESSION_NTRIALS){}
 
-void NDefNfcTagM24SR::OpenSessionCallBack::on_session_open(M24SR *nfc,
-		M24SR::StatusTypeDef status){
-	if(status==M24SR::M24SR_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::on_session_open(M24SR *nfc, M24SR::StatusTypeDef status) {
+	if (status==M24SR::M24SR_SUCCESS) {
 		nfc->select_application();
-	}else{
+	} else {
 		mSender.mCallBack->on_session_open(&mSender,false);
 	}
 }
 
-void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_application(M24SR *nfc,
-		M24SR::StatusTypeDef status){
-	if(status==M24SR::M24SR_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_application(M24SR *nfc, M24SR::StatusTypeDef status) {
+	if (status==M24SR::M24SR_SUCCESS) {
 		nfc->select_CC_file();
-	}else{
-		if(mNTrials==0)
+	} else {
+		if (mNTrials==0) {
 			mSender.mCallBack->on_session_open(&mSender,false);
-		else{
+		} else {
 			mNTrials--;
 			nfc->select_application();
 		}//if-else
 	}//if-else
 }
 
-void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_CC_file(M24SR *nfc,
-		M24SR::StatusTypeDef status){
-	if(status==M24SR::M24SR_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_CC_file(M24SR *nfc, M24SR::StatusTypeDef status) {
+	if (status==M24SR::M24SR_SUCCESS) {
 		nfc->read_binary(0x0000, CC_FILE_LENGTH_BYTE, CCFile);
-	}else{
+	} else {
 		mSender.mCallBack->on_session_open(&mSender,false);
 	}
 }
 
-void NDefNfcTagM24SR::OpenSessionCallBack::on_read_byte(M24SR *nfc,
-		M24SR::StatusTypeDef status,uint16_t offset,uint8_t *readByte, uint16_t nReadByte){
+void NDefNfcTagM24SR::OpenSessionCallBack::on_read_byte(M24SR *nfc, M24SR::StatusTypeDef status, uint16_t offset, uint8_t *readByte, uint16_t nReadByte) {
 	(void)offset;
-	if(status!=M24SR::M24SR_SUCCESS || nReadByte!=CC_FILE_LENGTH_BYTE){
+	if (status!=M24SR::M24SR_SUCCESS || nReadByte!=CC_FILE_LENGTH_BYTE) {
 		return mSender.mCallBack->on_session_open(&mSender,false);
 	}//else
 	uint16_t NDefFileId = (uint16_t) ((readByte[0x09] << 8) | readByte[0x0A]);
@@ -95,8 +91,7 @@
 	nfc->select_NDEF_file(NDefFileId);
 }
 
-void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_NDEF_file(M24SR *nfc,
-		M24SR::StatusTypeDef status){
+void NDefNfcTagM24SR::OpenSessionCallBack::on_selected_NDEF_file(M24SR *nfc, M24SR::StatusTypeDef status){
 	(void)nfc;
 
 	mSender.mIsSessionOpen = status==M24SR::M24SR_SUCCESS;
@@ -106,18 +101,17 @@
 
 bool NDefNfcTagM24SR::open_session(bool force) {
 
-	if (is_session_open()){
+	if (is_session_open()) {
 		mCallBack->on_session_open(this,true);
 		return true;
 	}
 
 	mDevice.set_callback(&mOpenSessionCallback);
-	if(force)
+	if (force) {
 		return mDevice.force_get_session() == M24SR::M24SR_SUCCESS;
-	else
+	} else {
 		return mDevice.get_session() == M24SR::M24SR_SUCCESS;
-
-
+	}
 }
 
 bool NDefNfcTagM24SR::close_session() {
@@ -126,26 +120,25 @@
 }
 
 void NDefNfcTagM24SR::WriteByteCallback::on_updated_binary(M24SR *nfc,
-		M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *writeByte,uint16_t nWriteByte){
+	M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *writeByte,uint16_t nWriteByte){
 
-	if(status!=M24SR::M24SR_SUCCESS){ // error -> finish to write
+	if (status!=M24SR::M24SR_SUCCESS){ // error -> finish to write
 		mCallback(mCallbackParam,false,mByteToWrite,mNByteToWrite);
 		return;
 	}//else
 
 	mByteWrote+=nWriteByte;
-	if(mByteWrote==mNByteToWrite){ //write all -> finish
+	if (mByteWrote==mNByteToWrite) { //write all -> finish
 		mCallback(mCallbackParam,true,mByteToWrite,mNByteToWrite);
-	}else{ //else write another slice
-		uint16_t tempLenght = std::min(mSender.mMaxWriteBytes,
-				(uint16_t)(mNByteToWrite-mByteWrote));
+	} else { //else write another slice
+		uint16_t tempLenght = std::min(mSender.mMaxWriteBytes, (uint16_t)(mNByteToWrite-mByteWrote));
 		nfc->update_binary(startOffset+nWriteByte,tempLenght,writeByte+nWriteByte);
 	}//if-else
 }
 
 bool NDefNfcTagM24SR::writeByte(const uint8_t *buffer, uint16_t length,uint16_t offset,
-		byteOperationCallback_t callback,CallbackStatus_t *callbackStatus){
-	if(!is_session_open())
+	byteOperationCallback_t callback,CallbackStatus_t *callbackStatus){
+	if (!is_session_open())
 		callback(callbackStatus,false,buffer,length);
 	//else
 	mWriteByteCallback.set_task(buffer,length,callback,callbackStatus);
@@ -153,34 +146,31 @@
 
 	if (length > mMaxWriteBytes) {
 		return mDevice.update_binary(offset, mMaxWriteBytes,(uint8_t*) buffer) == M24SR::M24SR_SUCCESS;
-	}else{
+	} else {
 		return mDevice.update_binary(offset,length,(uint8_t*)buffer) == M24SR::M24SR_SUCCESS;
 	}//if-else
-
 }
 
 void NDefNfcTagM24SR::ReadByteCallback::on_read_byte(M24SR *nfc,
-		M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *readBffer,uint16_t nReadByte){
+	M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *readBffer,uint16_t nReadByte){
 
-	if(status!=M24SR::M24SR_SUCCESS){ // error -> finish to write
+	if (status!=M24SR::M24SR_SUCCESS) { // error -> finish to write
 		mCallback(mCallbackParam,false,mBuffer,mNByteToRead);
 		return;
 	}//else
 
 	mByteRead += nReadByte;
-	if(mByteRead==mNByteToRead){ //read all -> finish
+	if (mByteRead==mNByteToRead) { //read all -> finish
 		mCallback(mCallbackParam,true,mBuffer,mNByteToRead);
-	}else{ //else write another slice
-		uint16_t tempLenght = std::min(mSender.mMaxReadBytes,
-				(uint16_t)(mNByteToRead-mByteRead));
+	} else { //else write another slice
+		uint16_t tempLenght = std::min(mSender.mMaxReadBytes, (uint16_t)(mNByteToRead-mByteRead));
 		nfc->read_binary(startOffset+nReadByte,tempLenght,readBffer+nReadByte);
 	}//if-else
-
 }
 
 bool NDefNfcTagM24SR::readByte(const uint16_t byteOffset, const uint16_t length,
-		uint8_t *buffer, byteOperationCallback_t callback,CallbackStatus_t *callbackStatus){
-	if(!is_session_open()){
+	uint8_t *buffer, byteOperationCallback_t callback,CallbackStatus_t *callbackStatus) {
+	if (!is_session_open()) {
 		return callback(callbackStatus,false,buffer,length);
 	}
 	//else
@@ -189,8 +179,7 @@
 
 	if (length > mMaxReadBytes) {
 		return mDevice.read_binary(byteOffset, mMaxReadBytes,buffer)== M24SR::M24SR_SUCCESS;;
-	}else{
+	} else {
 		return mDevice.read_binary(byteOffset,length,buffer)== M24SR::M24SR_SUCCESS;;
 	}//if-else
-
 }
--- a/m24sr/NDefNfcTagM24SR.h	Thu May 18 15:20:43 2017 +0000
+++ b/m24sr/NDefNfcTagM24SR.h	Wed Jul 12 14:15:02 2017 +0000
@@ -76,18 +76,19 @@
 	/**
 	* Close the open session.
 	*/
-	virtual ~NDefNfcTagM24SR(){
-		if(is_session_open())
+	virtual ~NDefNfcTagM24SR() {
+		if (is_session_open()) {
 			close_session();
+		}
 	}//~NDefNfcTagM24SR
 
 	protected:
 
 		virtual bool writeByte(const uint8_t *buffer, uint16_t length,uint16_t offset,
-				byteOperationCallback_t callback,CallbackStatus_t *callbackStatus);
+			byteOperationCallback_t callback,CallbackStatus_t *callbackStatus);
 
 		virtual bool readByte(const uint16_t byteOffset, const uint16_t byteLength,
-				uint8_t *buffer, byteOperationCallback_t callback,CallbackStatus_t *callbackStatus);
+			uint8_t *buffer, byteOperationCallback_t callback,CallbackStatus_t *callbackStatus);
 
 	private:
 
@@ -153,10 +154,10 @@
 
 				virtual void on_deselect(M24SR *nfc,M24SR::StatusTypeDef status){
 					(void)nfc;
-					if(status==M24SR::M24SR_SUCCESS){
-						mSender.mIsSessionOpen=false;
+					if (status==M24SR::M24SR_SUCCESS) {
+						mSender.mIsSessionOpen = false;
 						mSender.mCallBack->on_session_close(&mSender,true);
-					}else{
+					} else {
 						mSender.mCallBack->on_session_close(&mSender,false);
 					}//if-else
 				}
@@ -182,12 +183,12 @@
 				 * @param sender tag where write the buffer
 				 */
 				WriteByteCallback(NDefNfcTagM24SR &sender):
-									mByteToWrite(NULL),
-									mNByteToWrite(0),
-									mByteWrote(0),
-									mCallback(NULL),
-									mCallbackParam(NULL),
-									mSender(sender){}
+								  mByteToWrite(NULL),
+								  mNByteToWrite(0),
+								  mByteWrote(0),
+								  mCallback(NULL),
+								  mCallbackParam(NULL),
+								  mSender(sender){}
 
 				/**
 				 * Set the buffer to write and the function to call when finish
@@ -197,7 +198,7 @@
 				 * @param param Parameter to pass to the callback function.
 				 */
 				void set_task(const uint8_t *buffer,uint16_t nByte,
-						byteOperationCallback_t callback,CallbackStatus_t *param){
+					byteOperationCallback_t callback,CallbackStatus_t *param) {
 					mByteToWrite=buffer;
 					mNByteToWrite=nByte;
 					mByteWrote=0;
@@ -206,7 +207,7 @@
 				}
 
 				virtual void on_updated_binary(M24SR *nfc,M24SR::StatusTypeDef status,
-						uint16_t startOffset,uint8_t *writeByte,uint16_t nWriteByte);
+					uint16_t startOffset,uint8_t *writeByte,uint16_t nWriteByte);
 
 
 			private:
@@ -241,12 +242,12 @@
 				 * @param Sender tag where read the buffer
 				 */
 				ReadByteCallback(NDefNfcTagM24SR &sender):
-										mBuffer(NULL),
-										mNByteToRead(0),
-										mByteRead(0),
-										mCallback(NULL),
-										mCallbackParam(NULL),
-										mSender(sender){}
+								 mBuffer(NULL),
+								 mNByteToRead(0),
+								 mByteRead(0),
+								 mCallback(NULL),
+								 mCallbackParam(NULL),
+								 mSender(sender){}
 
 				/**
 				 * Set the buffer where read the data and the function to call when finish
@@ -256,7 +257,7 @@
 				 * @param param Parameter to pass to the callback function
 				 */
 				void set_task(uint8_t *buffer,uint16_t nByte,
-						byteOperationCallback_t callback,CallbackStatus_t *param){
+					byteOperationCallback_t callback,CallbackStatus_t *param){
 					mBuffer=buffer;
 					mNByteToRead=nByte;
 					mByteRead=0;
@@ -265,7 +266,7 @@
 				}
 
 				virtual void on_read_byte(M24SR *nfc,M24SR::StatusTypeDef status,
-						uint16_t offset,uint8_t *readByte, uint16_t nReadByte);
+					uint16_t offset,uint8_t *readByte, uint16_t nReadByte);
 
 
 			private: