![](/media/cache/group/ST_logo_2020_blue_V_cmyk.jpg.50x50_q85.jpg)
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: Samples/SampleSync_lockWriteTag.cpp
- Revision:
- 15:94c98d2aa235
- Parent:
- 14:3b604972b89f
- Child:
- 17:d8d3d2088cac
diff -r 3b604972b89f -r 94c98d2aa235 Samples/SampleSync_lockWriteTag.cpp --- a/Samples/SampleSync_lockWriteTag.cpp Wed Aug 31 13:06:13 2016 +0000 +++ b/Samples/SampleSync_lockWriteTag.cpp Wed Aug 31 13:58:17 2016 +0000 @@ -71,6 +71,7 @@ bool enableReadOnly( X_NUCLEO_NFC01A1 *nfcNucleo){ if(nfcNucleo->getM24SR().EnableReadOnly(M24SR::DEFAULT_PASSWORD)){ + printf("Enable Read Only\r\n"); getReadOnlyLed(nfcNucleo)=true; getWriteableLed(nfcNucleo)=false; return true; @@ -87,6 +88,7 @@ bool disableReadOnly( X_NUCLEO_NFC01A1 *nfcNucleo){ if(nfcNucleo->getM24SR().DisableReadOnly(M24SR::DEFAULT_PASSWORD)){ + printf("Disable Read Only\r\n"); getReadOnlyLed(nfcNucleo)=false; getWriteableLed(nfcNucleo)=true; return true; @@ -107,7 +109,9 @@ //when the user press the button set buttonPress to true InterruptIn userButton(USER_BUTTON); userButton.fall(setButtonPress); - + + printf("Init Done\r\n"); + //restore the board as read/write tag.openSession(true); nfcNucleo->getM24SR().DisableAllPassword(M24SR::DEFAULT_PASSWORD); @@ -115,7 +119,9 @@ getReadOnlyLed(nfcNucleo)=false; getWriteableLed(nfcNucleo)=true; bool tagIsLock=false; - + + printf("All Protection removed\r\n"); + nfcNucleo->getLed1()=true; while(true){ @@ -123,7 +129,7 @@ if(tag.openSession()){ bool changeStatusResult; - if(tagIsLock) + if(!tagIsLock) changeStatusResult=enableReadOnly(nfcNucleo); else changeStatusResult=disableReadOnly(nfcNucleo);