nRF5 SDK v17.1.0
NFC Connection Handover Message Parser

This SDK provides a Connection Handover message parser to support the BLE Central role in BLE NFC pairing. It allows to process the given NFC tag data and get important pairing data, such as device name, device address, and OOB keys used for authentication. Parsing data may be obtained for example by using the Adafruit PN532 NFC shield - see Adafruit NFC Shield library.

This parsing module collects data that allows to perform various BLE pairing modes:

  1. Legacy Just Works pairing,
  2. Legacy Out Of Band pairing,
  3. LE Secure Connections Just Works pairing,
  4. LE Secure Connections Out Of Band pairing.

Usage

An example of module usage is provided by Experimental: BLE Heart Rate Collector Example with NFC Pairing example. It can be tested with a complementary Experimental: Heart Rate Application with BLE Pairing Using NFC Pairing Library example. To properly use the Connection Handover message parser, perform the following steps:

  1. Obtain NFC tag data using an NFC reader.
  2. Split the NFC tag data into NDEF messages.
  3. Parse each NDEF message with the parser, assuming that they are Connection Handover messages:
    /**
    * @brief Function for analyzing Connection Handover NDEF message.
    */
    void ch_ndef_msg_handle(nfc_ndef_msg_desc_t * p_ch_msg_desc)
    {
    nfc_ble_oob_pairing_data_t le_oob_record_pairing_data;
    uint8_t device_name[DEVICE_NAME_BUFF_SIZE];
    ble_gap_lesc_oob_data_t device_lesc_data;
    for (uint8_t i = 0; i < p_ch_msg_desc->record_count; i++)
    {
    le_oob_record_pairing_data.device_name.p_name = device_name;
    le_oob_record_pairing_data.device_name.len = sizeof(device_name);
    le_oob_record_pairing_data.p_device_addr = &device_lesc_data.addr;
    le_oob_record_pairing_data.p_tk_value = &device_tk;
    le_oob_record_pairing_data.p_lesc_confirm_value = (uint8_t *)device_lesc_data.c;
    le_oob_record_pairing_data.p_lesc_random_value = (uint8_t *)device_lesc_data.r;
    // Parse an NDEF message, assuming it is a Connection Handover message.
    ret_code_t err_code = nfc_le_oob_rec_parse(p_ch_msg_desc->pp_record[i],
    &le_oob_record_pairing_data);
    if (err_code == NRF_SUCCESS)
    {
    nfc_oob_data_printout(&le_oob_record_pairing_data);
  4. Use pairing data to establish a connection with a BLE Peripheral device.

Documentation feedback | Developer Zone | Subscribe | Updated