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
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
Diff: Interfaces/Nfc_class.h
- Revision:
- 23:d07138541feb
- Parent:
- 21:ccc4f3fed4b3
- Child:
- 24:9f98eafa2d39
--- a/Interfaces/Nfc_class.h Fri Jan 29 15:06:30 2016 +0000
+++ b/Interfaces/Nfc_class.h Mon Feb 01 15:32:40 2016 +0000
@@ -60,7 +60,7 @@
* thought a callback.
* The default behavior is sync mode.
* For enable the async mode you have to call the ManageI2CGPO(I2C_ANSWER_READY) function.
- * Then when an interrupt happen you have to call the {@link ManageInterrupt} function.
+ * When the component notify an interrupt you have to call the {@link ManageInterrupt} function.
* Note that when you call ManageI2CGPO with other parameters the component will return in sync mode.
*/
class Nfc : public Component
@@ -76,6 +76,10 @@
I2CPwd, //!< Root password, used only thought nfc
}PasswordType_t;
+ /**
+ * Function that will be called when an interrupt is fired,
+ * this function must be set if you want use the component in async mode.
+ */
typedef void(*gpoEventCallback)(void);
/**
@@ -231,7 +235,7 @@
virtual NFC_StatusTypeDef SelectCCfile(void) = 0;
/**
- * Select the ndef file.
+ * Select the NDEF file.
* @param NDEFfileId File id to open.
* @return NFC_SUCCESS if the file is selected
*/
@@ -330,6 +334,8 @@
* @brief This function configures GPO for I2C session.
* @param GPO_I2Cconfig GPO configuration to set.
* @return NFC_SUCCESS if no errors
+ * @par if the configuration is I2C_ANSWER_READY, the component will start to work
+ * in async mode.
*/
virtual NFC_StatusTypeDef ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) = 0;
@@ -355,8 +361,8 @@
virtual NFC_StatusTypeDef SendInterrupt(void)=0;
/**
- * Change the function to call when a command ends
- * @param commandCallback object containings the callback, if NULL it will use empty callback
+ * Change the function to call when a command ends.
+ * @param commandCallback Object containing the callback, if NULL it will use empty callback
*/
void SetCallback(Callback *commandCallback){
if(commandCallback!=NULL)
@@ -366,7 +372,7 @@
}
/**
- * function to call when the component fire an interrupt
+ * Function to call when the component fire an interrupt.
* @return last operation status
*/
virtual NFC_StatusTypeDef ManageEvent()=0;
@@ -381,7 +387,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef enableReadPassword(const uint8_t* pCurrentWritePassword,
+ NFC_StatusTypeDef EnableReadPassword(const uint8_t* pCurrentWritePassword,
const uint8_t* pNewPassword) {
//enable the callback for change the gpo
@@ -397,7 +403,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef disableReadPassword(const uint8_t* pCurrentWritePassword) {
+ NFC_StatusTypeDef DisableReadPassword(const uint8_t* pCurrentWritePassword) {
mComponentCallback = &mChangePasswordRequestStatusCallback;
mChangePasswordRequestStatusCallback.setTask(ReadPwd,NULL);
@@ -411,7 +417,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef enableWritePassword(const uint8_t* pCurrentWritePassword,
+ NFC_StatusTypeDef EnableWritePassword(const uint8_t* pCurrentWritePassword,
uint8_t* pNewPassword) {
//enable the callback for change the gpo
mComponentCallback = &mChangePasswordRequestStatusCallback;
@@ -426,7 +432,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef disableWritePassword(const uint8_t* pCurrentWritePassword) {
+ NFC_StatusTypeDef DisableWritePassword(const uint8_t* pCurrentWritePassword) {
mComponentCallback = &mChangePasswordRequestStatusCallback;
mChangePasswordRequestStatusCallback.setTask(WritePwd,NULL);
@@ -439,9 +445,8 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef disableAllPassword(const uint8_t* pSuperUserPassword){
+ NFC_StatusTypeDef DisableAllPassword(const uint8_t* pSuperUserPassword){
mComponentCallback = &mRemoveAllPasswordCallback;
- mRemoveAllPasswordCallback.setPwd(pSuperUserPassword);
return Verify(Nfc::I2CPwd, 0x10, pSuperUserPassword);
}
@@ -451,13 +456,13 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef enableReadOnly(const uint8_t* pCurrentWritePassword){
+ NFC_StatusTypeDef EnableReadOnly(const uint8_t* pCurrentWritePassword){
mComponentCallback = &mChangeAccessStateCallback;
//disable write = read only
mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::WRITE,false);
- return Verify(Nfc::I2CPwd, 0x10, pCurrentWritePassword);
+ return Verify(Nfc::WritePwd, 0x10, pCurrentWritePassword);
}
/**
@@ -466,7 +471,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef disableReadOnly(const uint8_t* pCurrentWritePassword) {
+ NFC_StatusTypeDef DisableReadOnly(const uint8_t* pCurrentWritePassword) {
mComponentCallback = &mChangeAccessStateCallback;
mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::WRITE,true);
return Verify(Nfc::I2CPwd, 0x10,pCurrentWritePassword);
@@ -479,13 +484,13 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef enableWriteOnly(const uint8_t* pCurrentWritePassword) {
+ NFC_StatusTypeDef EnableWriteOnly(const uint8_t* pCurrentWritePassword) {
mComponentCallback = &mChangeAccessStateCallback;
//disable read = enable write only
mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::READ,false);
- return Verify(Nfc::I2CPwd, 0x10, pCurrentWritePassword);
+ return Verify(Nfc::WritePwd, 0x10, pCurrentWritePassword);
}
@@ -495,7 +500,7 @@
* @return return NFC_SUCCESS if no errors
* @par The password must have a length of 16 chars.
*/
- NFC_StatusTypeDef disableWriteOnly(const uint8_t* pCurrentWritePassword) {
+ NFC_StatusTypeDef DisableWriteOnly(const uint8_t* pCurrentWritePassword) {
mComponentCallback = &mChangeAccessStateCallback;
mChangeAccessStateCallback.changeAccessState(ChangeAccessStateCallback::READ,true);
return Verify(Nfc::I2CPwd, 0x10, pCurrentWritePassword);
@@ -530,7 +535,7 @@
/**
- * This class permit to enable/disable the password request for read/write into the tag
+ * This class permit to enable/disable the password request to read/write into the tag
* This class is equivalent to call the method:
* To enable the request:
* <ul>
@@ -625,14 +630,15 @@
};
- friend class ChangePasswordRequestStatusCallback;
+
/**
* Object containing the callback chain needed to change the password request
*/
ChangePasswordRequestStatusCallback mChangePasswordRequestStatusCallback;
+ friend class ChangePasswordRequestStatusCallback;
/**
- * This class permit to disable all the password request for read/write into the tag
+ * This class permit to disable all the password request to read/write into the tag
* This class is equivalent to call the methods:
* <ul>
* <li> Verify(i2c) </li>
@@ -646,6 +652,10 @@
*/
class RemoveAllPasswordCallback : public Nfc::Callback{
+ /**
+ * 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:
@@ -656,14 +666,11 @@
*/
RemoveAllPasswordCallback():mI2CPwd(NULL){}
- void setPwd(const uint8_t *pwd){
- mI2CPwd = pwd;
- }
-
virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status,
- PasswordType_t,const uint8_t*){
+ PasswordType_t,const uint8_t* data){
if(status!=NFC_SUCCESS)
return onFinishCommand(nfc,status);
+ mI2CPwd = data;
nfc->DisablePermanentState(ReadPwd);
}
@@ -712,11 +719,12 @@
};
- friend class RemoveAllPasswordCallback;
+
/**
* Object containing the callback chain needed remove the password request
*/
RemoveAllPasswordCallback mRemoveAllPasswordCallback;
+ friend class RemoveAllPasswordCallback;
/**
* This class permit set the tag as read/write only
@@ -748,9 +756,9 @@
ChangeAccessStateCallback():mType(WRITE),mEnable(false){}
/**
- * Set the access to enable/disable
- * @param type Type to enable or disable
- * @param enable true for enable the state, false for disable it
+ * Set the access to enable/disable.
+ * @param type Type to enable or disable.
+ * @param enable true for enable the state, false for disable it.
*/
void changeAccessState(AccessType_t type,bool enable){
mType=type;
@@ -819,11 +827,12 @@
};
- friend class ChangeAccessStateCallback;
+
/**
* Object containing the callback chain needed to change the access state
*/
ChangeAccessStateCallback mChangeAccessStateCallback;
+ friend class ChangeAccessStateCallback;
};

X-NUCLEO-NFC01A1 Dynamic NFC Tag