NFC: Text record
The NFC Text record sample shows how to use the NFC tag to expose a text record to NFC polling devices. It uses the NFC Data Exchange Format (NDEF).
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10095 |
|
||
PCA10040 |
|
||
PCA10056 |
|
When built for an _ns
build target, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
The sample also requires a smartphone or tablet.
Overview
When the sample starts, it initializes the NFC tag and generates an NDEF message with three text records that contain the text “Hello World!” in three languages. Then it sets up the NFC library to use the generated message and sense the external NFC field.
The only events handled by the application are the NFC events.
User interface
- LED 1:
Indicates if an NFC field is present.
Building and running
This sample can be found under samples/nfc/record_text
in the nRF Connect SDK folder structure.
When built as firmware image for the _ns
build target, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE).
Because of this, it automatically includes the Trusted Firmware-M (TF-M).
To read more about CMSE, see Processing environments.
To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Building and programming an application for other building and programming scenarios and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.
Note
If you are using debug messages in the NFCT driver, the driver might not be working properly if you have CONFIG_LOG_MODE_IMMEDIATE
enabled.
The NFCT driver is part of the nrfx driver package.
For more information about this driver, see the NFCT driver page in the nrfx repository.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Touch the NFC antenna with the smartphone or tablet and observe that LED 1 is lit.
Observe that the smartphone or tablet displays the encoded text (in the most suitable language).
Move the smartphone or tablet away from the NFC antenna and observe that LED 1 turns off.
Dependencies
This sample uses the following nRF Connect SDK libraries:
In addition, it uses the Type 2 Tag library from sdk-nrfxlib:
It uses the following Zephyr libraries:
include/zephyr.h
include/device.h
include/power/reboot.h
The sample also uses the following secure firmware component: