NB-IoT
Dependencies: NDefLib X_NUCLEO_NFC02A1 hdc1080 mbed
Fork of HelloWorld_NFC02A1 by
Revision 14:e191f376520f, committed 2018-04-06
- Comitter:
- ThijsBuuron
- Date:
- Fri Apr 06 11:56:09 2018 +0000
- Parent:
- 13:17208d6d9971
- Commit message:
- test
Changed in this revision
hdc1080-test.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hdc1080-test.lib Fri Apr 06 11:56:09 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/joeata2wh/code/hdc1080/#dd3a07b44fe2
--- a/main.cpp Wed Jul 12 12:35:47 2017 +0000 +++ b/main.cpp Fri Apr 06 11:56:09 2018 +0000 @@ -40,7 +40,12 @@ #include "DevI2C.h" #include "NDefLib/NDefNfcTag.h" #include "NDefLib/RecordType/RecordURI.h" - +#include "NDefLib/RecordType/RecordText.h" +//Pin Defines for I2C Bus +#define D_SDA D14 // specific for Nucleo-F303K8 +#define D_SCL D15 // specific for Nucleo-F303K8 +I2C hdc_i2c(D_SDA, D_SCL); +#include "hdc1080.h" static volatile bool buttonPress = false; // true when the user press the message /** @@ -111,7 +116,7 @@ /* Creating the NDef message and record. */ NDefLib::Message msg; - NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"st.com/st25"); + NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"st.com/test"); msg.add_record(&rUri); /* Writing the tag. */ @@ -143,9 +148,56 @@ /* Each second change the led status and see if the user press the button. */ while(1) { if (buttonPress) { - /* Writing the read message on console. */ - read_and_print_nfc_tag(tag); - buttonPress=false; + /* Writing the read message on console. */ + read_and_print_nfc_tag(tag); + buttonPress=false; + + printf("\r\\nHDC1080 Test\r\n"); + hdc_begin(); + uint16_t manId = hdc_readManufactId(); + float tempC = hdc_readTemp(); + float humid = hdc_readHumid(); + unsigned long serNum = hdc_readSerial(); + printf("manId=x%x, tempC=%0.3f humid=%0.3f serfNum=%ld\r\n", + manId, tempC, humid, serNum); + char temp = tempC; + NDefLib::NDefNfcTag& tag =nfcNucleo->get_M24LR().get_NDef_tag(); + M24LR & mM24LRp = nfcNucleo->get_M24LR(); + + /* Enabling Energy Harvesting. */ + mM24LRp.enable_energy_harvesting(); + + printf("System Initialization done: !\n\r"); + + /* Opening the i2c session with the nfc chip. */ + if (tag.open_session() == true) { + printf("Session opened\n\r"); + nfcNucleo->get_led1() = 1; + + /* Creating the NDef message and record. */ + NDefLib::Message msg; + NDefLib::RecordText test(&temp); + msg.add_record(&test); + + /* Writing the tag. */ + if (tag.write(msg) == true) { + printf("Tag written\n\r"); + nfcNucleo->get_led2() = 1; + } else { + printf("Error writing \n\r"); + nfcNucleo->get_led1() = 0; + } //if-else + + /* Closing the i2c session. */ + if (tag.close_session() == true) { + printf("Session closed\n\r"); + nfcNucleo->get_led3() = 1; + } else { + printf("Error closing the session\n\r"); + } //if-else + } else { + printf("Error opening the session\n\r"); + } } } #else