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

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.

Static Handover

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.

Negotiated Handover

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF5340 DK

PCA10095

nrf5340dk_nrf5340

nrf5340dk_nrf5340_cpuapp

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF52833 DK

PCA10100

nrf52833dk_nrf52833

nrf52833dk_nrf52833

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

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.

See Building and programming an application for information about how to build and program the application.

Testing

After programming the sample to your development kit, test it by performing the following steps:

  1. 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.

  2. Observe the output log. The content of the exchanged NDEF messages is printed there.

  3. Check the security level of the paring on the terminal.

  4. Move the NFC antenna away from the NFC Reader ST25R3911B.

  5. Press Button 3 when connected to turn on the NFC Reader ST25R3911B field and initialize new pairing.

  6. Press Button 4 for disconnect and erase bonding data.