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

Revision:
21:ccc4f3fed4b3
Parent:
20:aad5727cb8c6
Child:
23:d07138541feb
--- a/m24sr/m24sr_class.cpp	Thu Jan 28 16:38:30 2016 +0000
+++ b/m24sr/m24sr_class.cpp	Fri Jan 29 15:06:30 2016 +0000
@@ -284,6 +284,7 @@
 	errchk(M24SR_KillSession())
 	//leave the gpo always up
 	errchk(M24SR_ManageI2CGPO(DEFAULT_GPO_STATUS))
+	errchk(M24SR_ManageRFGPO(DEFAULT_GPO_STATUS))
 	//close the session
 	errchk(M24SR_Deselect())
 	mGpoEventInterrupt.enable_irq();
@@ -916,7 +917,7 @@
 
 	/*check the parameters */
 	if ((uPwdId > 0x0003)|| ((NbPwdByte != 0x00) && (NbPwdByte != 0x10))) {
-		getCallback()->onVerifyed(this,NFC_IO_ERROR_PARAMETER);
+		getCallback()->onVerifyed(this,NFC_IO_ERROR_PARAMETER,constToPasswordType(uPwdId),pPwd);
 		return NFC_IO_ERROR_PARAMETER;
 	}
 
@@ -945,17 +946,21 @@
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
 	if(status!=NFC_SUCCESS){
-		getCallback()->onVerifyed(this,status);
+		getCallback()->onVerifyed(this,status,constToPasswordType(uPwdId),pPwd);
 		return status;
 	}
 	mLastCommandSend=VERIFY;
+
+	mLastCommandData.data=(uint8_t*)pPwd;
+	mLastCommandData.offset=uPwdId;
+
 	if(mCommunicationType==M24SR::SYNC){
 		status = M24SR_IO_PollI2C();
 		if(status == NFC_SUCCESS)
 			return M24SR_ReceiveVerify();
 		else{
 			mLastCommandSend = NONE;
-			getCallback()->onVerifyed(this,status);
+			getCallback()->onVerifyed(this,status,constToPasswordType(uPwdId),pPwd);
 			return status;
 		}
 	}
@@ -968,15 +973,18 @@
 	uint8_t respBuffer[M24SR_STATUSRESPONSE_NBBYTE];
 	mLastCommandSend=NONE;
 
+	const uint8_t *data = mLastCommandData.data;
+	const PasswordType_t type = constToPasswordType(mLastCommandData.offset);
+
 	status=M24SR_IO_ReceiveI2Cresponse (sizeof(respBuffer),respBuffer);
 
 	if(status !=NFC_SUCCESS){
-		getCallback()->onVerifyed(this,status);
+		getCallback()->onVerifyed(this,status,type,data);
 		return status;
 	}
 
 	status = M24SR_IsCorrectCRC16Residue(respBuffer, M24SR_STATUSRESPONSE_NBBYTE);
-	getCallback()->onVerifyed(this,status);
+	getCallback()->onVerifyed(this,status,type,data);
 	return status;
 }
 
@@ -1569,76 +1577,5 @@
 	}//switch
 }//manageInterrupt
 
-////////////////////////hight level utility function //////////////////////////
-
-NFC_StatusTypeDef M24SR::enableReadPassword(const uint8_t* pCurrentWritePassword,
-			const uint8_t* pNewPassword) {
-
-	//enable the callback for change the gpo
-	mComponentCallback = &mChangePasswordRequestStatusCallback;
-	mChangePasswordRequestStatusCallback.setTask(ReadPwd,pNewPassword);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-}
-
-NFC_StatusTypeDef M24SR::disableReadPassword(const uint8_t* pCurrentWritePassword) {
-	mComponentCallback = &mChangePasswordRequestStatusCallback;
-	mChangePasswordRequestStatusCallback.setTask(ReadPwd,NULL);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-}
-
-NFC_StatusTypeDef M24SR::enableWritePassword(const uint8_t* pCurrentWritePassword,
-			uint8_t* pNewPassword) {
-	//enable the callback for change the gpo
-	mComponentCallback = &mChangePasswordRequestStatusCallback;
-	mChangePasswordRequestStatusCallback.setTask(WritePwd,pNewPassword);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-}
-
-NFC_StatusTypeDef M24SR::disableWritePassword(const uint8_t* pCurrentWritePassword) {
-	mComponentCallback = &mChangePasswordRequestStatusCallback;
-	mChangePasswordRequestStatusCallback.setTask(WritePwd,NULL);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-}
-
-NFC_StatusTypeDef M24SR::disableAllPassword(const uint8_t* pSuperUserPassword){
-	mComponentCallback = &mRemoveAllPasswordCallback;
-	return Verify(M24SR::I2CPwd, 0x10, pSuperUserPassword);
-}
-
-NFC_StatusTypeDef M24SR::enableReadOnly(const uint8_t* pCurrentWritePassword){
-
-	mComponentCallback = &mChangeAccessStateCallback;
-	//disable write = read only
-	mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::WRITE,false);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-}
-
-NFC_StatusTypeDef M24SR::disableReadOnly() {
-	mComponentCallback = &mChangeAccessStateCallback;
-	mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::WRITE,true);
-	return Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD);
-}
-
-	
-NFC_StatusTypeDef M24SR::enableWriteOnly(const uint8_t* pCurrentWritePassword) {
-
-	mComponentCallback = &mChangeAccessStateCallback;
-	//disable read = enable write only
-	mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::READ,false);
-
-	return Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword);
-
-}
-
-NFC_StatusTypeDef M24SR::disableWriteOnly() {
-	mComponentCallback = &mChangeAccessStateCallback;
-	mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::READ,true);
-	return Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD);
-}
 
 /******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/