nRF5 SDK v17.1.0
Writable NDEF Message Example

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 Flash Data Storage (FDS) 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

Note
This application is not power optimized!

Button assignments:

When the device resets, press Button 1 to restore the default NDEF message.

Testing

Test the Writable NDEF Message Example with a smartphone or a tablet with NFC support by performing the following steps:

  1. Compile and program the application.
  2. Touch the NFC antenna with a smartphone or a tablet and observe that LED 1 and LED 4 are lit.
  3. Observe that the smartphone/tablet tries to open the URL "http://www.nordicsemi.com" in a web browser.
  4. Use a proper application (e.g. NFC Tools for Android) to overwrite the existing NDEF message with your own message.
  5. Observe that LED 2 is lit after a successful overwrite.
  6. Move the smartphone/tablet away from the NFC antenna and observe that all LEDs are turned off.
  7. After resetting, the device will load the last written NDEF message.

Documentation feedback | Developer Zone | Subscribe | Updated