This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
Dependencies: NDefLib X_NUCLEO_NFC01A1 mbed
Fork of X-MBED-NFC1 by
This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
The available demos are:
- SAMPLE_WRITE_URL: write a tag with the ST home page URL
- SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
- SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
- SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.
To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .
Diff: Type4NfcTagSTM24SR.cpp
- Revision:
- 2:0648c1561eb2
- Parent:
- 1:6d202b62ed68
--- a/Type4NfcTagSTM24SR.cpp Fri Nov 27 15:10:25 2015 +0000
+++ b/Type4NfcTagSTM24SR.cpp Tue Dec 01 08:30:54 2015 +0000
@@ -16,7 +16,7 @@
bool Type4NfcTagSTM24SR::openSession(bool force) {
- if (mSessionIsOpen)
+ if (isSessionOpen())
return true;
//else
if (force)
@@ -54,29 +54,28 @@
if (mDevice.SelectNDEFfile(ndefFileId) != NFC_SUCCESS)
return false;
- mSessionIsOpen = true;
+ Type4NfcTag::openSession();
return true;
}
bool Type4NfcTagSTM24SR::closeSession() {
//no open session
- if (!mSessionIsOpen)
+ if (!isSessionOpen())
return true;
//close the CC file
if (mDevice.Deselect() != NFC_SUCCESS)
return false;
- mSessionIsOpen = false;
+ Type4NfcTag::closeSession();
return true;
}
-bool Type4NfcTagSTM24SR::writeByte(uint8_t *buffer, uint16_t length) {
+bool Type4NfcTagSTM24SR::writeByte(const uint8_t *buffer, uint16_t length, uint16_t offset) {
NFC_StatusTypeDef status = NFC_SUCCESS;
- uint16_t offset = 0;
- bool prevSessionStatus = mSessionIsOpen;
+ bool prevSessionStatus = isSessionOpen();
if (!prevSessionStatus) {
//try to acquire a session or fail
if (openSession(false))
@@ -85,7 +84,7 @@
if (length > mMaxWriteBytes) {
do {
- status = mDevice.UpdateBinary(offset, mMaxWriteBytes, buffer);
+ status = mDevice.UpdateBinary(offset, mMaxWriteBytes,(uint8_t*) buffer);
offset += mMaxWriteBytes;
buffer += mMaxWriteBytes;
length -= mMaxWriteBytes;
@@ -94,7 +93,7 @@
//finish to write the buffer
if (status == NFC_SUCCESS && mMaxWriteBytes)
- status = mDevice.UpdateBinary(offset, length, buffer);
+ status = mDevice.UpdateBinary(offset, length,(uint8_t*) buffer);
if (status == NFC_SUCCESS) {
if (!prevSessionStatus) // if the session was closed, try close it
