
A simple application providing an example of asynchronous access to the X-NUCLEO_NFC01A1 Dynamic NFC Tag board.
Dependencies: NDefLib X_NUCLEO_NFC01A1 mbed
Fork of HelloWord_Async_NFC01A1 by
X-NUCLEO-NFC01A1 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-NFC01A1 Dynamic NFC Tag Expansion Board based on M24SR.
Example Application
The application provides a simple example of asynchronous access to the X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board. The program writes a URI link to the M24SR dynamic tag using the asynchronous programming model. The URI can then be retrieved from an NFC enabled smartphone/tablet.
A simpler example providing synchronous access to the tag is also available.
Diff: WriteUriCallbacks.h
- Revision:
- 10:a7834e6dd638
- Parent:
- 7:cd34abf10350
--- a/WriteUriCallbacks.h Tue Aug 08 12:42:16 2017 +0000 +++ b/WriteUriCallbacks.h Mon Aug 21 12:20:40 2017 +0000 @@ -44,7 +44,7 @@ DigitalOut &mOnOpenSession; DigitalOut &mOnWrite; DigitalOut &mOnCloseSession; - NDefLib::Message msg; + NDefLib::Message mMsg; public: @@ -71,10 +71,11 @@ //ask to have an interrupt when the command finish mOnOpenSession=1; - NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"http://www.st.com"); - msg.add_record(&rUri); + NDefLib::RecordURI *rUri = + new NDefLib::RecordURI(NDefLib::RecordURI::HTTP_WWW,"http://www.st.com"); + mMsg.add_record(rUri); - tag->write(msg); + tag->write(mMsg); } /** @@ -83,9 +84,8 @@ * @param success true if the message is correctly wrote * @param message wrote */ - virtual void on_message_write(NDefLib::NDefNfcTag *tag,bool success, - const NDefLib::Message&) { - + virtual void on_message_write(NDefLib::NDefNfcTag *tag,bool success) { + NDefLib::Message::remove_and_delete_all_record(mMsg); if (!success) { printf("Error writing tag!\r\n"); } else {