Complete mbed library/workspace for HelloWorld_NFC02A1

Dependencies:   NDefLib X_NUCLEO_NFC02A1 mbed

Fork of HelloWorld_NFC02A1 by ST Expansion SW Team

X-NUCLEO-NFC02A1 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-NFC02A1 Dynamic NFC Tag Expansion Board based on M24LR.

Example Application

This is just a simple "hello world" style program for the X-NUCLEO-NFC02A1 Dynamic NFC Tag Expansion Board. The program writes a URI link to the M24LR dynamic tag using the synchronous programming model. It then reads back the URI from the tag to display it on terminal. The URI can also be retrieved from an NFC enabled smartphone/tablet.

Revision:
2:6f1b1f7f8d12
Parent:
1:11ae12d41082
Child:
7:699836375630
--- a/main.cpp	Tue Aug 30 09:18:50 2016 +0000
+++ b/main.cpp	Wed Sep 28 11:26:49 2016 +0000
@@ -40,7 +40,6 @@
 #include "X_NUCLEO_NFC02A1.h"
 #include "DevI2C.h"
 #include "m24lr.h"
-
 #include "NDefLib/NDefNfcTag.h"
 #include "NDefLib/RecordType/RecordURI.h"
 /**
@@ -56,51 +55,51 @@
                                                            X_NUCLEO_NFC02A1::DEFAULT_LED1_PIN,X_NUCLEO_NFC02A1::DEFAULT_LED2_PIN,
                                                            X_NUCLEO_NFC02A1::DEFAULT_LED3_PIN);
   
- NDefLib::NDefNfcTag& tag =nfcNucleo->getM24LR().getNDefTag();
- M24LR & mM24LRp = nfcNucleo->getM24LR();
- // mNDEF_URI.setM24LR(mM24LRp);
+  NDefLib::NDefNfcTag& tag =nfcNucleo->getM24LR().getNDefTag();
+  M24LR & mM24LRp = nfcNucleo->getM24LR();
+  
   /* Enable Energy Harvesting */
   mM24LRp.Enable_EnergyHarvesting();
   
   printf("System Initialization done: !\n\r");
   
-  //open the i2c session with the nfc chip
-    if(tag.openSession())
+  /*open the i2c session with the nfc chip*/
+  if(tag.openSession() == NFC_SUCCESS)
+  {
+    printf("Session opened\n\r");
+    nfcNucleo->getLed1()=1;
+    
+    /*create the NDef message and record*/
+    NDefLib::Message msg;
+    NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"st.com");
+    msg.addRecord(&rUri);
+    
+    /*write the tag*/
+    if(tag.write(msg) == NDEF_OK){
+      printf("Tag written\n\r");
+      nfcNucleo->getLed2()=1;
+    }else{
+      printf("Error writing \n\r");
+      nfcNucleo->getLed1()=0;
+    }//if-else
+    
+    /*close the i2c session*/
+    if(tag.closeSession() == NFC_SUCCESS)
     {
-        printf("Session opened\n\r");
-        nfcNucleo->getLed1()=1;
-        
-        //create the NDef message and record
-        NDefLib::Message msg;
-        NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"st.com");
-        msg.addRecord(&rUri);
-
-        //write the tag
-        if(tag.write(msg) == NDEF_OK)
-        {
-            printf("Tag written\n\r");
-            nfcNucleo->getLed2()=1;
-        }
-        else
-        {
-            printf("Error writing \n\r");
-            nfcNucleo->getLed1()=0;
-        }//if-else
-
-        //close the i2c session
-        if(tag.closeSession())
-        {
-           printf("Session closed\n\r");
-           nfcNucleo->getLed3()=1;
-        }
-        else
-        {
-           printf("Error closing the session\n\r");
-        }//if-else
-            
+      printf("Session closed\n\r");
+      nfcNucleo->getLed3()=1;
     }
     else
-        printf("Error opening the session\n\r");
-  
+    {
+      printf("Error closing the session\n\r");
+    }//if-else
+    
+  }
+  else
+    printf("Error opening the session\n\r");
 }
 
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 
+