Bluetooth: Central NFC pairing
The Central NFC pairing sample demonstrates Bluetooth® LE out-of-band pairing using an NFC Reader ST25R3911B and the NFC TNEP protocol. You can use it to test the touch-to-pair feature between Nordic Semiconductor’s devices with NFC Reader ST25R3911B and an NFC Tag device with Bluetooth LE support.
The sample shows the usage of NFC NDEF Connection Handover messages and records and TNEP for polling device with the Connection Handover service. It provides minimal Bluetooth functionality in the Central role, and on GATT level it implements only the Device Information Service.
The sample supports pairing in one of the following modes:
LE Secure Connections Just Works pairing
LE Secure Connections OOB pairing
Legacy OOB pairing
Legacy Just Works pairing
Negotiated Handover (TNEP protocol) - two-way OOB pairing
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Board target |
---|---|---|---|
PCA10095 |
|
||
PCA10040 |
|
||
PCA10056 |
|
The sample has the following additional requirements:
NFC Reader ST25R3911B Nucleo expansion board (X-NUCLEO-NFC05A1)
NFC Tag 2 Tag device or NFC Tag 4 Tag device
Overview
When the sample starts, it initializes and starts the NFC Reader ST25R3911B, and waits for a Type 2 Tag or a Type 4 Tag to appear in the field. When the tag is detected, the sample identifies its type, then reads it, and parses its content. After successful parsing, the tag content is printed on the serial port. The sample does not start scanning immediately, but only when the NFC tag is read by an NFC Poller, or when the exchange of data over the TNEP Connection Handover Service is finished.
NFC data exchange
This sample can read Bluetooth LE OOB data from the Static NFC Tag or exchange the OOB data with an NFC Tag device with TNEP support.
Static Handover
A tag in the Static Handover mode, contains a Handover Select Message with carrier information NDEF records or a single Carrier Configuration Record.
Negotiated Handover
In Negotiated Handover, two NFC Forum Devices identify a matching set of alternative carriers by exchanging lists of potential alternative carriers. In case of the OOB data for Bluetooth LE the NFC Devices can exchange OOB data 2-ways. Handover messages are exchanged using the TNEP Single response communication mode. The NFC Poler Device can be the Handover Requester or Handover Selector Device, the role is taken based on the NFC Tag first NDEF message.
User interface
- Button 3:
Turns on NFC Field to detect next NFC Tag Device with Bluetooth LE OOB data.
- Button 4:
Removes all bonded devices and terminates current connections. Turns on the NFC Field if it is inactive after last operation.
Building and running
This sample can be found under samples/bluetooth/central_nfc_pairing
in the nRF Connect SDK folder structure.
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.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Touch the NFC Reader ST25R3911B with a Type 2 Tag or Tag 4 Tag. The Tag Device can support the TNEP protocol. You can use the corresponding Bluetooth: NFC pairing sample as the Tag Device. This sample supports the TNEP.
Observe the output log. The content of the exchanged NDEF messages is printed there.
Check the security level of the paring on the terminal.
Move the NFC antenna away from the NFC Reader ST25R3911B.
Press Button 3 when connected to turn on the NFC Reader ST25R3911B field and initialize new pairing.
Press Button 4 to disconnect and erase bonding data.
Dependencies
This sample uses the following nRF Connect SDK libraries:
The sample uses the following Zephyr libraries:
include/zephyr.h
include/device.h