nRF5 SDK v17.1.0
NFC BLE pairing library

The NFC BLE Pairing library is a high level module that uses NFC technology to establish a BLE connection. It integrates SDK modules such as Peer Manager, Advertising Module, and NFC Type 2 Tag to provide easy-to-use API for basic Connection Handover pairing scenarios. It is also a good starting point to develop more sophisticated pairing procedures.

Library supports five Connection Handover pairing modes:

Architecture overview

The library uses BLE pairing message generation to encode the Connection Handover NDEF message with BLE advertising data into the NFC Type 2 Tag. It also takes advantage of the Tag 2 Type emulation to dynamically change security key values on each NFC_T2T_EVENT_FIELD_ON event. For more information on BLE Connection Handover message, refer to the NFC Forum Application Document Bluetooth Secure Simple Pairing Using NFC.

Depending on the pairing mode, the library sets up proper Peer Manager security parameters and Connection Handover message data. It also generates random TK and LESC OOB keys values and responds to BLE authentication events. For more information on security parameters configuration, refer to the Bluetooth Core Specification Volume 3 Part H Chapter 2.

Advertising Module is used to automatically turn on fast advertising when NFC module detects the field and Tag data is obtained by the reader. Advertising is disabled after the BLE connection has been established or a timeout has occurred. The library also turns on directed advertising when connection timeout occurs due to link loss.

Library usage

Library usage is based on the Experimental: Heart Rate Application with BLE Pairing Using NFC Pairing Library example. To properly set up the library, perform the following steps:

  1. Configure Peer Manager security parameters settings - they are located in the SDK configuration header file.
  2. Add nfc_ble_pair_on_pm_params_req to the Peer Manager event handler to react on PM_EVT_CONN_SEC_PARAMS_REQ event:
    {
    // Send event to the NFC BLE pairing library as it may dynamically alternate
    // security parameters to achieve highest possible security level.
    err_code = nfc_ble_pair_on_pm_params_req(p_evt);
    APP_ERROR_CHECK(err_code);
    } break;
  3. Initialize and enable the SoftDevice
  4. Initialize Peer Manager and Advertising Module with the fast advertising mode enabled
  5. Initialize the library by issuing a call to the nfc_ble_pair_init function:
    ble_stack_init();
    gap_params_init();
    gatt_init();
    peer_manager_init(erase_bonds);
    if (erase_bonds)
    {
    NRF_LOG_INFO("Bonds erased!");
    }
    advertising_init();
    nrf_ble_pairing_init();
    When these steps are finished, the library is ready to support establishing BLE connections by means of NFC. You can also call the nfc_ble_pair_mode_set function to change the pairing mode.

Documentation feedback | Developer Zone | Subscribe | Updated