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:
giovannivisentini
Date:
Tue Jan 12 14:24:42 2016 +0000
Parent:
8:5e637c71cbb3
Commit message:
Nfc_class doesn't depent by m24sr.h;

Changed in this revision

Interfaces/Nfc_class.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
m24sr/m24sr_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/Interfaces/Nfc_class.h	Mon Jan 11 13:06:23 2016 +0000
+++ b/Interfaces/Nfc_class.h	Tue Jan 12 14:24:42 2016 +0000
@@ -48,7 +48,7 @@
 /* Includes ------------------------------------------------------------------*/
 
 #include "Component_class.h"
-
+#include "nfc.h"
 
 /* Classes  ------------------------------------------------------------------*/
 
@@ -62,9 +62,9 @@
 	 * possible password to set
 	 */
 	typedef enum{
-		ReadPwd=READ_PWD,  //!< password to use before read the tag
-		WritePwd=WRITE_PWD,//!< password to use before write the tag
-		I2CPwd=I2C_PWD,    //!< root password, used only thought nfc
+		ReadPwd,  //!< password to use before read the tag
+		WritePwd,//!< password to use before write the tag
+		I2CPwd,    //!< root password, used only thought nfc
 	}PasswordType_t;
 
 
--- a/m24sr/NDefNfcTagM24SR.cpp	Mon Jan 11 13:06:23 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp	Tue Jan 12 14:24:42 2016 +0000
@@ -34,7 +34,7 @@
   */
 
 #include "NDefNfcTagM24SR.h"
-#include "m24sr_class.h"
+#include "Nfc_class.h"
 /* wait 1sec, driver is configured to let 200ms for command to complete */
 /* which is enough for all commands except GetSession if RF session is already opened */
 /* Smartphone generaly release the session within the second, but customer can modify this value */
--- a/m24sr/NDefNfcTagM24SR.h	Mon Jan 11 13:06:23 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.h	Tue Jan 12 14:24:42 2016 +0000
@@ -37,9 +37,10 @@
 #define NDEFNFCTAGSTM24_H_
 #include <stdint.h>
 
+#include "Nfc_class.h"
 #include "NDefLib/NDefNfcTag.h"
 
-class M24SR;
+
 
 /**
  * implement the abstract method for use the NDefLib */
@@ -50,9 +51,9 @@
 	 * create the object
 	 * @param device device where write the Ndef tags
 	 */
-	NDefNfcTagM24SR(M24SR &device) :
-			mDevice(device), mMaxReadBytes(0xFF), mMaxWriteBytes(
-					0xFF) {
+	NDefNfcTagM24SR(Nfc &device) :
+			mDevice(device), mMaxReadBytes(0xFF),
+			 mMaxWriteBytes(0xFF) {
 	}
 
 	/**
@@ -103,7 +104,7 @@
 
 private:
 
-	M24SR &mDevice;
+	Nfc &mDevice;
 
 	/**
 	 * max length for a read operation
--- a/m24sr/m24sr_class.h	Mon Jan 11 13:06:23 2016 +0000
+++ b/m24sr/m24sr_class.h	Tue Jan 12 14:24:42 2016 +0000
@@ -163,26 +163,26 @@
 	
 	virtual NFC_StatusTypeDef Verify(PasswordType_t pwdId, uint8_t NbPwdByte,
 			const uint8_t *pPwd) {
-		return (NFC_StatusTypeDef) M24SR_Verify((uint16_t) pwdId,
+		return (NFC_StatusTypeDef) M24SR_Verify(passTypeToIntFlag(pwdId),
 				(uint8_t) NbPwdByte, pPwd);
 	}
 
 	virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t pwdId,
 			const uint8_t *pPwd) {
-		return (NFC_StatusTypeDef) M24SR_ChangeReferenceData((uint16_t) pwdId,
+		return (NFC_StatusTypeDef) M24SR_ChangeReferenceData(passTypeToIntFlag(pwdId),
 				(uint8_t *) pPwd);
 	}
 
 	virtual NFC_StatusTypeDef EnableVerificationRequirement(
 			PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_EnableVerificationRequirement(
-				(uint16_t) uReadOrWrite);
+				passTypeToIntFlag(uReadOrWrite));
 	}
 
 	virtual NFC_StatusTypeDef DisableVerificationRequirement(
 			PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_DisableVerificationRequirement(
-				(uint16_t) uReadOrWrite);
+				passTypeToIntFlag(uReadOrWrite));
 	}
 
     ////////////////////// ST proprietary //////////////////////////////////
@@ -197,12 +197,12 @@
 
 	virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_EnablePermanentState(
-				(uint16_t) uReadOrWrite);
+				passTypeToIntFlag(uReadOrWrite));
 	}
 
 	virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_DisablePermanentState(
-				(uint16_t) uReadOrWrite);
+				passTypeToIntFlag(uReadOrWrite));
 	}
 
 	///////////////////// chip configuration /////////////////////////////////
@@ -272,6 +272,12 @@
 	NFC_StatusTypeDef enableWritePassword(const uint8_t* pCurrentWritePassword,
 			uint8_t* pNewPassword);
 
+    /**
+	 * disable the request of a password before write the tag
+	 * @param pCurrentWritePassword current password ( use M24SR::DEFAULT_PASSWORD if it is the first time)
+	 * @return return NFC_SUCCESS if no error happen
+	 * @par the password must have a length of 16 char
+	 */
 	NFC_StatusTypeDef disableWritePassword(const uint8_t* pCurrentWritePassword=M24SR::DEFAULT_PASSWORD);
 
 	/**
@@ -466,6 +472,26 @@
 	 * Object implementing the interface for use the NDefLib
 	 */
 	NDefNfcTagM24SR NDefTagUtil;
+	
+private:
+
+	/**
+	 * Convert a enum file into a M24SR constant
+	 * @param pass type of password
+	 * @return equvalent constant used in the m24sr device
+	 */
+	uint16_t passTypeToIntFlag(const PasswordType_t &pass){
+		switch(pass){
+			case ReadPwd:
+				return READ_PWD;
+			case WritePwd:
+				return WRITE_PWD;
+			case I2CPwd:
+			default:
+				return I2C_PWD;
+		}//switch
+	}//passTypeToIntFlag
+	
 };
 
 #endif // __M24SR_CLASS_H