NFC: Launch App
The NFC Launch App sample shows how to use the NFC tag to launch an app on the polling smartphone. It uses the NFC Data Exchange Format (NDEF) library.
Requirements
This sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
|
|---|---|---|---|
nRF7120 DK |
nrf7120dk |
|
|
PCA10184 |
|
||
PCA10156 |
|
||
PCA10156 |
|
||
PCA10156 |
|
||
PCA10175 |
|
||
PCA10095 |
|
||
PCA10040 |
|
||
PCA10056 |
|
For more security, it is recommended to use the */ns variant of the board target.
When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation.
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 a tablet. You need to have the nRF Toolbox app installed for iOS devices.
Overview
When the sample starts, it initializes the NFC tag and generates an NDEF message with two records that contain the app Universal Link and Android Application Record. 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.
- LED 0:
Indicates if an NFC field is present.
Building and running
This sample can be found under samples/nfc/record_launch_app in the nRF Connect SDK folder structure.
For more security, it is recommended to use the */ns variant of the board target (see the Requirements section above.)
When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.
Note
When building repository applications in the SDK repositories, building with sysbuild is enabled by default.
If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.
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 launches the nRF Toolbox application.
Move the smartphone or tablet away from the NFC antenna and observe that LED 1 turns off.
Touch the NFC antenna with the smartphone or tablet and observe that LED 0 is lit.
Observe that the smartphone or tablet launches the nRF Toolbox application.
Move the smartphone or tablet away from the NFC antenna and observe that LED 0 turns off.
Note
Devices running iOS require the nRF Toolbox app to be installed before testing the sample. Devices running Android open Google Play when the application is not installed.
Dependencies
This sample uses the following nRF Connect SDK libraries:
In addition, it uses the Type 2 Tag library from sdk-nrfxlib:
The sample uses the following Zephyr libraries:
include/zephyr.hinclude/power/reboot.h
The sample also uses the following secure firmware component: