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: m24sr/NDefNfcTagM24SR.cpp
- Revision:
- 27:3881985097bb
- Parent:
- 24:9f98eafa2d39
- Child:
- 29:7a2dfd06cb29
--- a/m24sr/NDefNfcTagM24SR.cpp Wed Feb 03 09:01:05 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp Fri Sep 30 12:33:20 2016 +0000
@@ -2,8 +2,8 @@
******************************************************************************
* @file NdefNfcTagSTM24SR.cpp
* @author ST Central Labs
- * @version V1.0.0
- * @date 05 Nov 2015
+ * @version V1.1.0
+ * @date 30 Set 2016
* @brief Wrapper class of the NDefLib library to write/read NDEF messages
******************************************************************************
* @attention
@@ -51,18 +51,18 @@
OpenSessionCallBack(NDefNfcTagM24SR& sender):
mSender(sender),mNTrials(OPENSESSION_NTRIALS){}
-void NDefNfcTagM24SR::OpenSessionCallBack::onSessionOpen(Nfc *nfc,
- NFC_StatusTypeDef status){
- if(status==NFC_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::onSessionOpen(M24SR *nfc,
+ M24SR::StatusTypeDef status){
+ if(status==M24SR::M24SR_SUCCESS){
nfc->SelectApplication();
}else{
mSender.mCallBack->onSessionOpen(&mSender,false);
}
}
-void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedApplication(Nfc *nfc,
- NFC_StatusTypeDef status){
- if(status==NFC_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedApplication(M24SR *nfc,
+ M24SR::StatusTypeDef status){
+ if(status==M24SR::M24SR_SUCCESS){
nfc->SelectCCfile();
}else{
if(mNTrials==0)
@@ -74,19 +74,19 @@
}//if-else
}
-void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedCCFile(Nfc *nfc,
- NFC_StatusTypeDef status){
- if(status==NFC_SUCCESS){
+void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedCCFile(M24SR *nfc,
+ M24SR::StatusTypeDef status){
+ if(status==M24SR::M24SR_SUCCESS){
nfc->ReadBinary(0x0000, CC_FILE_LENGTH_BYTE, CCFile);
}else{
mSender.mCallBack->onSessionOpen(&mSender,false);
}
}
-void NDefNfcTagM24SR::OpenSessionCallBack::onReadByte(Nfc *nfc,
- NFC_StatusTypeDef status,uint16_t offset,uint8_t *readByte, uint16_t nReadByte){
+void NDefNfcTagM24SR::OpenSessionCallBack::onReadByte(M24SR *nfc,
+ M24SR::StatusTypeDef status,uint16_t offset,uint8_t *readByte, uint16_t nReadByte){
(void)offset;
- if(status!=NFC_SUCCESS || nReadByte!=CC_FILE_LENGTH_BYTE){
+ if(status!=M24SR::M24SR_SUCCESS || nReadByte!=CC_FILE_LENGTH_BYTE){
return mSender.mCallBack->onSessionOpen(&mSender,false);
}//else
uint16_t NDefFileId = (uint16_t) ((readByte[0x09] << 8) | readByte[0x0A]);
@@ -95,10 +95,11 @@
nfc->SelectNDEFfile(NDefFileId);
}
-void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedNDEFFile(Nfc *nfc,
- NFC_StatusTypeDef status){
+void NDefNfcTagM24SR::OpenSessionCallBack::onSelectedNDEFFile(M24SR *nfc,
+ M24SR::StatusTypeDef status){
(void)nfc;
- mSender.mIsSessionOpen = status==NFC_SUCCESS;
+
+ mSender.mIsSessionOpen = status==M24SR::M24SR_SUCCESS;
mSender.mCallBack->onSessionOpen(&mSender,mSender.mIsSessionOpen);
}
////////////////////////////END OpenSessionCallBack/////////////////////////
@@ -112,22 +113,22 @@
mDevice.SetCallback(&mOpenSessionCallback);
if(force)
- return mDevice.ForceGetSession() == NFC_SUCCESS;
+ return mDevice.ForceGetSession() == M24SR::M24SR_SUCCESS;
else
- return mDevice.GetSession() == NFC_SUCCESS;
+ return mDevice.GetSession() == M24SR::M24SR_SUCCESS;
}
bool NDefNfcTagM24SR::closeSession() {
mDevice.SetCallback(&mCloseSessionCallback);
- return mDevice.Deselect() == NFC_SUCCESS;
+ return mDevice.Deselect() == M24SR::M24SR_SUCCESS;
}
-void NDefNfcTagM24SR::WriteByteCallback::onUpdatedBinary(Nfc *nfc,
- NFC_StatusTypeDef status,uint16_t startOffset, uint8_t *writeByte,uint16_t nWriteByte){
+void NDefNfcTagM24SR::WriteByteCallback::onUpdatedBinary(M24SR *nfc,
+ M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *writeByte,uint16_t nWriteByte){
- if(status!=NFC_SUCCESS){ // error -> finish to write
+ if(status!=M24SR::M24SR_SUCCESS){ // error -> finish to write
mCallback(mCallbackParam,false,mByteToWrite,mNByteToWrite);
return;
}//else
@@ -151,17 +152,17 @@
mDevice.SetCallback(&mWriteByteCallback);
if (length > mMaxWriteBytes) {
- return mDevice.UpdateBinary(offset, mMaxWriteBytes,(uint8_t*) buffer) == NFC_SUCCESS;
+ return mDevice.UpdateBinary(offset, mMaxWriteBytes,(uint8_t*) buffer) == M24SR::M24SR_SUCCESS;
}else{
- return mDevice.UpdateBinary(offset,length,(uint8_t*)buffer) == NFC_SUCCESS;
+ return mDevice.UpdateBinary(offset,length,(uint8_t*)buffer) == M24SR::M24SR_SUCCESS;
}//if-else
}
-void NDefNfcTagM24SR::ReadByteCallback::onReadByte(Nfc *nfc,
- NFC_StatusTypeDef status,uint16_t startOffset, uint8_t *readBffer,uint16_t nReadByte){
+void NDefNfcTagM24SR::ReadByteCallback::onReadByte(M24SR *nfc,
+ M24SR::StatusTypeDef status,uint16_t startOffset, uint8_t *readBffer,uint16_t nReadByte){
- if(status!=NFC_SUCCESS){ // error -> finish to write
+ if(status!=M24SR::M24SR_SUCCESS){ // error -> finish to write
mCallback(mCallbackParam,false,mBuffer,mNByteToRead);
return;
}//else
@@ -187,9 +188,9 @@
mDevice.SetCallback(&mReadByteCallback);
if (length > mMaxReadBytes) {
- return mDevice.ReadBinary(byteOffset, mMaxReadBytes,buffer)== NFC_SUCCESS;;
+ return mDevice.ReadBinary(byteOffset, mMaxReadBytes,buffer)== M24SR::M24SR_SUCCESS;;
}else{
- return mDevice.ReadBinary(byteOffset,length,buffer)== NFC_SUCCESS;;
+ return mDevice.ReadBinary(byteOffset,length,buffer)== M24SR::M24SR_SUCCESS;;
}//if-else
}

X-NUCLEO-NFC01A1 Dynamic NFC Tag