mbed OS 5 example application using X-NUCLEO-NFC02A1
Dependencies: NDefLib X_NUCLEO_NFC02A1
Fork of HelloWorld_NFC02A1 by
Revision 11:d0665d9c28a6, committed 2017-05-19
- Comitter:
- giovannivisentini
- Date:
- Fri May 19 07:51:59 2017 +0000
- Parent:
- 10:64a38017f5c8
- Child:
- 12:85bf9d143843
- Commit message:
- update with ARM mBed coding style + update libs
Changed in this revision
--- a/NDefLib.lib Wed Oct 12 09:39:57 2016 +0000 +++ b/NDefLib.lib Fri May 19 07:51:59 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST/code/NDefLib/#46899fa3d9f2 +https://developer.mbed.org/teams/ST/code/NDefLib/#13d84b136a62
--- a/X_NUCLEO_NFC02A1.lib Wed Oct 12 09:39:57 2016 +0000 +++ b/X_NUCLEO_NFC02A1.lib Fri May 19 07:51:59 2017 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST/code/X_NUCLEO_NFC02A1/#900640bf1cff +http://developer.mbed.org/teams/ST/code/X_NUCLEO_NFC02A1/#8c1eca41b3a9
--- a/main.cpp Wed Oct 12 09:39:57 2016 +0000
+++ b/main.cpp Fri May 19 07:51:59 2017 +0000
@@ -37,45 +37,44 @@
#include "mbed.h"
-#include "X_NUCLEO_NFC02A1.h"
+#include "XNucleoNFC02A1.h"
#include "DevI2C.h"
-#include "m24lr.h"
#include "NDefLib/NDefNfcTag.h"
#include "NDefLib/RecordType/RecordURI.h"
static volatile bool buttonPress=false; // true when the user press the message
-static void setButtonPress(){
+static void set_button_press(){
buttonPress=true;
}//if buttonPress
- static void readAndPrintNfcTag(NDefLib::NDefNfcTag &tag){
+ static void read_and_print_nfc_tag(NDefLib::NDefNfcTag &tag){
using namespace NDefLib;
- if(tag.openSession() == true){
+ if(tag.open_session() == true){
printf("Open Session\r\n");
NDefLib::Message readMsg;
tag.read(&readMsg);
printf("Message Read\r\n");
- if(readMsg.getNRecords()==0){
+ if(readMsg.get_N_records()==0){
printf("Error Read\r\n");
}else{
- for(uint32_t i=0;i<readMsg.getNRecords();i++){
+ for(uint32_t i=0;i<readMsg.get_N_records();i++){
Record *r = readMsg[i];
// printRecord(r);
//-----
RecordURI *const temp = (RecordURI*)r;
- printf("Read uriId: %d\r\n",temp->getUriId());
- printf("Read uriType: %s\r\n",temp->getUriType().c_str());
- printf("Read uriContent: %s\r\n",temp->getContent().c_str());
+ printf("Read uriId: %d\r\n",temp->get_uri_id());
+ printf("Read uriType: %s\r\n",temp->get_uri_type().c_str());
+ printf("Read uriContent: %s\r\n",temp->get_content().c_str());
//------
delete r;
}//for
}//if-else
- tag.closeSession();
+ tag.close_session();
printf("Close session\r\n");
}else{
printf("Error open read Session\n\r");
@@ -90,48 +89,48 @@
{
/*use default board pinout*/
- DevI2C i2cChannel(X_NUCLEO_NFC02A1::DEFAULT_SDA_PIN,X_NUCLEO_NFC02A1::DEFAULT_SDL_PIN);
- X_NUCLEO_NFC02A1 *nfcNucleo = X_NUCLEO_NFC02A1::Instance(i2cChannel,
- X_NUCLEO_NFC02A1::DEFAULT_GPO_PIN,X_NUCLEO_NFC02A1::DEFAULT_RF_DISABLE_PIN,
- X_NUCLEO_NFC02A1::DEFAULT_LED1_PIN,X_NUCLEO_NFC02A1::DEFAULT_LED2_PIN,
- X_NUCLEO_NFC02A1::DEFAULT_LED3_PIN);
+ DevI2C i2cChannel(XNucleoNFC02A1::DEFAULT_SDA_PIN,XNucleoNFC02A1::DEFAULT_SDL_PIN);
+ XNucleoNFC02A1 *nfcNucleo = XNucleoNFC02A1::instance(i2cChannel,
+ XNucleoNFC02A1::DEFAULT_GPO_PIN,XNucleoNFC02A1::DEFAULT_RF_DISABLE_PIN,
+ XNucleoNFC02A1::DEFAULT_LED1_PIN,XNucleoNFC02A1::DEFAULT_LED2_PIN,
+ XNucleoNFC02A1::DEFAULT_LED3_PIN);
- NDefLib::NDefNfcTag& tag =nfcNucleo->getM24LR().getNDefTag();
- M24LR & mM24LRp = nfcNucleo->getM24LR();
+ NDefLib::NDefNfcTag& tag =nfcNucleo->get_M24LR().get_NDef_tag();
+ M24LR & mM24LRp = nfcNucleo->get_M24LR();
/* Enable Energy Harvesting */
- mM24LRp.Enable_EnergyHarvesting();
+ mM24LRp.enable_energy_harvesting();
printf("System Initialization done: !\n\r");
/*open the i2c session with the nfc chip*/
- if(tag.openSession() == true)
+ if(tag.open_session() == true)
{
printf("Session opened\n\r");
- nfcNucleo->getLed1()=1;
+ nfcNucleo->get_led1()=1;
/*create the NDef message and record*/
NDefLib::Message msg;
NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"st.com/st25");
- msg.addRecord(&rUri);
+ msg.add_record(&rUri);
/*write the tag*/
if(tag.write(msg) == true)
{
printf("Tag written\n\r");
- nfcNucleo->getLed2()=1;
+ nfcNucleo->get_led2()=1;
}
else
{
printf("Error writing \n\r");
- nfcNucleo->getLed1()=0;
+ nfcNucleo->get_led1()=0;
}//if-else
/*close the i2c session*/
- if(tag.closeSession() == true)
+ if(tag.close_session() == true)
{
printf("Session closed\n\r");
- nfcNucleo->getLed3()=1;
+ nfcNucleo->get_led3()=1;
}
else
{
@@ -146,7 +145,7 @@
/* enable the button */
InterruptIn mybutton(USER_BUTTON);
- mybutton.fall(setButtonPress);
+ mybutton.fall(set_button_press);
/*each second change the led status and see if the user press the button*/
while(1)
@@ -154,12 +153,12 @@
if(buttonPress)
{
/*write the read message on console*/
- readAndPrintNfcTag(tag);
+ read_and_print_nfc_tag(tag);
buttonPress=false;
}
}
#else
- readAndPrintNfcTag(tag);
+ read_and_print_nfc_tag(tag);
#endif
}
--- a/mbed.bld Wed Oct 12 09:39:57 2016 +0000 +++ b/mbed.bld Fri May 19 07:51:59 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725 \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file
