nRF5 SDK v17.1.0
Experimental: BLE Pairing Using NFC - Central Reference Example
This example requires the following SoftDevice: S132

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

The aim of this example is to provide a reference BLE Central application that presents the BLE Connection Handover pairing using the Adafruit PN532 NFC Shield. This application also shows the usage of the Connection Handover Parser library. The example can be used to test the touch-to-pair feature with BLE Peripheral devices that have an NFC tag. You can also find a complementary BLE Peripheral example in this SDK that can be used with this application for BLE Connection Handover pairing.

To simplify the pairing tests, this application uses minimal BLE functionalities. It does not read any GATT services. It allows to perform pairing in one of four different modes:

The pairing mode is determined by the Connection Handover message that is located in the Peripheral device NFC tag and by the BLE Central device security flags set in the Peer Manager. For more information about BLE Connection Handover pairing, refer to the NFC Forum Application Document Bluetooth Secure Simple Pairing Using NFC.

When the application starts, it initializes the NFC reader and the BLE stack. When you press Button 4, the device attempts to read NFC tags. After a tag with BLE Connection Handover message has been found, the application starts BLE scanning. It searches for an advertising device whose address is the same as the address embedded in the NFC tag and tries to pair with it.

Note
This application is not power optimized!

Setup

Since the SoftDevice does not include the functionality required to calculate Elliptic Curve Cryptography (ECC) public keys and shared secrets, an external library is required for this purpose. Bindings and build files are provided for a well-known open source library, micro-ecc, although the library itself is not provided.

To use micro-ecc with this project, follow the steps described in Installing micro-ecc.

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

Button assignments:

Use the buttons to control the device:

Testing

Test this application with a smartphone or tablet that supports NFC. It can also be tested with the complementary BLE Peripheral example. Perform the following steps:

  1. Compile and program the application.
  2. Press Button 4 to start pairing, then touch the NFC Shield antenna with the BLE Peripheral NFC antenna. This will start the pairing process.
  3. Press Button 3 to disconnect or erase bonding data.
  4. Press Button 4 when connected to initialize new pairing. The current connection will be terminated when the device finds another NFC tag with Connection Handover data.

Documentation feedback | Developer Zone | Subscribe | Updated