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 Giovanni Visentini

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 .

Revision:
18:d596eb3f575f
Parent:
17:d8d3d2088cac
Child:
20:ba95e0dc5975
diff -r d8d3d2088cac -r d596eb3f575f Samples/SampleAsync_countClick.cpp
--- a/Samples/SampleAsync_countClick.cpp	Thu Jul 13 09:41:01 2017 +0000
+++ b/Samples/SampleAsync_countClick.cpp	Thu Jul 13 12:46:03 2017 +0000
@@ -1,6 +1,6 @@
 /**
   ******************************************************************************
-  * @file       Sample_countClick.cpp
+  * @file       SampleAsync_countClick.cpp
   * @author     ST / Central Labs
   * @date       03 Dic 2015
   * @brief      This demo define a custom record that contains the number of time the user
@@ -84,8 +84,9 @@
 		void update_message(){
 			if(mCommandFinish){
 				mNfcNucleo->get_M24SR().get_NDef_tag().open_session();
-			}else// if it is doing something remember this request
+			}else{// if it is doing something remember this request
 				mRequestRefresh=true;
+			}
 		}//updateMessage
 
 	private:
@@ -111,15 +112,17 @@
 		 */
 		virtual void on_message_write(NDefLib::NDefNfcTag *tag,bool success,
 				const NDefLib::Message&){
-			if(!success)
+			if(!success) {
 				return on_error();
+			}
 			mNfcNucleo->get_led2()=!mNfcNucleo->get_led2();
 			printf("Tag wrote\r\n");
 			if(mRequestRefresh){
 				mRequestRefresh=false;
 				tag->write(mMsg);
-			}else
+			}else {
 				tag->close_session();
+			}
 			//if-else
 
 		};
@@ -135,8 +138,9 @@
 			if(mRequestRefresh){
 				mRequestRefresh=false;
 				tag->open_session();
-			}else
+			}else {
 				mCommandFinish=true;
+			}
 			//if-else
 		};
 
@@ -177,8 +181,9 @@
     M24SR &nfcTag =nfcNucleo->get_M24SR();
 
    //No call back needed since default behavior is sync
-    if(nfcTag.get_session()==M24SR::M24SR_SUCCESS)
+    if(nfcTag.get_session()==M24SR::M24SR_SUCCESS) {
     	nfcTag.manage_I2C_GPO(M24SR::I2C_ANSWER_READY);//Set async mode
+	}
 
     //create the NDef message and record
     NDefLib::Message msg;
@@ -207,4 +212,3 @@
     }//while
 
 }//sample_countClick
-