nRF5 SDK v12.1.0
Experimental: Heart Rate Application with BLE pairing using NFC
This information applies to the nRF52 Series only.
This example requires the following SoftDevice: S132

Important: Before you run this example, make sure to program the SoftDevice.

This example is based on the BLE Peripheral Heart Rate Application example. It implements the Heart Rate profile and enables pairing from a BLE Central device using the NFC interface. To do the pairing, it uses the NFC tag module that is one of the nRF52 peripherals and the NFC antenna that is delivered with the nRF52 Development Kit.

The application shows the usage of the BLE pairing message generation module. It includes the same services that are present in the original Heart Rate Application example. See the documentation for that example for details. The following description presents only the differences from the original example.

When the application starts, it initializes and starts the NFCT peripheral, which is used for pairing. The application does not start advertising immediately, but only when the NFC tag is read by an NFC polling device, for example a smartphone or a tablet with NFC support. The message that the tag sends to the NFC device contains data required to initiate pairing. To start the NFC data transfer, the NFC device must touch the NFC antenna that is connected to the nRF52 Development Kit.

After reading the tag, the device can pair with the nRF52 device which is advertising. After connecting, the example application behaves the same way as the original HRS example. Reading the NFC tag again when the application is in a connected state does not start advertising. When the pairing is successful, new NFC tag data is configured to launch nRF Toolbox app. When the connection is lost, advertising does not restart automatically. The NFC tag must be read again to restart advertising with whitelist, so only the paired peer can connect. Reading the tag will not trigger pairing. To pair with a different device, remove bonding information by pressing Button 2 on application startup. When there is no bonding information, the NFC tag data is configured to trigger pairing again, using a BLE pairing message.

Only one NFC transfer is required to connect to the nRF52 device and get the heart rate measurements using the Heart Rate Monitor application for Android or Windows Phone. For this, the application uses a Handover Select NDEF message (see BLE pairing message generation). However, you can easily modify the application to use only one LE OOB NDEF message (and support only Android) or only one EP OOB NDEF message (and support only Windows Phone).

Note
This application is not power optimized!
This example uses a constant value for the Temporary Key for OOB pairing. To be compatible with the BLE Core Specification for OOB pairing, generate a random value for the Temporary key.
This application supports pairing with just one peer.

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\experimental_ble_app_hrs_pairing_nfc

Button assignments: BSP BLE Button Assignments

Testing

Test the Heart Rate Application with BLE pairing using NFC with a smartphone or tablet (with Android or Windows Phone) that supports NFC by performing the following steps:

  1. Compile and program the application.
  2. Touch the NFC antenna with the smartphone or tablet and observe that the BSP_INDICATE_ADVERTISING state is indicated. LED 4 is lit when the NFC tag detects the NFC field.
  3. Confirm pairing with 'Nordic_HRM' in a pop-up window on the smartphone/tablet and observe that the BSP_INDICATE_CONNECTED state is indicated.
  4. Test the Heart Rate Application using the nRF Toolbox app.

Documentation feedback | Developer Zone | Subscribe | Updated