The Writable NDEF Message Example shows how to use the NFC tag to expose an NDEF message, which can be overwritten with any other NDEF message by an NFC device.
When the application starts, it initializes the NFC tag and loads the NDEF message from the file in flash memory. If the NDEF message file does not exist, a default message is generated: an URI message with an URI record containing the URL "nordicsemi.com". Then, it sets up the NFC library for Type 4 Tag platform, which uses the NDEF message, and senses the external NFC field. The library works in Read-Write emulation mode. In this mode, procedures for reading and updating an NDEF message are handled internally by the NFC library. Any changes in NDEF message update the NDEF message file which is stored in flash memory.
The only events handled by the application are the NFC events. Each of these events is related to following LEDs actions:
NFC event | LED action |
---|---|
NFC field on | LED 1 is lit. |
NDEF message read | LED 4 is lit. |
NDEF message updated | LED 2 is lit. |
NFC field off | All LEDs are turned off. |
The Writable NDEF Message Example shows the usage of the NFC Type 4 Tag and the URI message generation modules. It also uses the Experimental: Flash Data Storage module to store the NDEF message in flash memory.
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\nfc\writable_ndef_msg
Button assignments:
When the device resets, press Button 1 to restore the default NDEF message.
Test the Writable NDEF Message Example with a smartphone or a tablet with NFC support by performing the following steps: