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.
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 Software backend (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:
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: