![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
NB-IoT
Dependencies: NDefLib X_NUCLEO_NFC02A1 hdc1080 mbed
Fork of HelloWorld_NFC02A1 by
Diff: main.cpp
- 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****/ +