This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

OOB pairing central

Hi! I am trying to implement oob pairing, but I don't know how to do it. I' ve got 2 nrf devices. Central and peripheral. Central receives oob data, which it stores in structure. What I've done now is presented below.

Central side:

  1. Getting some information like peripheral address, peripheral tk value.
  2. Connecting with device (in BLE_GAP_EVT_ADV_REPORT I check ble address and if it matches I call sd_ble_gap_connect).
  3. Discovering peer services: (in DM_EVT_CONNECTION useble_db_discovery_start).
  4. Initiating bonding procedure. In service handler as reply of event: BLE_MY_SERVICE_C_EVT_DISCOVERY_COMPLETE I usedm_security_setup_req.

On the peripheral side:

  1. Creating advdata with my uuids, like in example: experimental_ble_app_hrs_pairing_nfc.
  2. Using conn_params_init() with the difference: cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID;
  3. Calling ble_advertising_start(BLE_ADV_MODE_FAST);. (I replace ble_advdata.h and ble_advdata.c to new one from nrf52 sdk).
  4. In the case BLE_GAP_EVT_AUTH_KEY_REQUEST: using err_code = sd_ble_gap_auth_key_reply(p_ble_evt->evt.gap_evt.conn_handle, BLE_GAP_AUTH_KEY_TYPE_OOB, m_oob_auth_key.tk);

And that's all. It does not work. Where I made a mistake?

  • Shouldn't you get the BLE_GAP_EVT_AUTH_KEY_REQUEST on the central side as well? And reply with sd_ble_gap_auth_key_reply()? See this MSC.

  • I realized that function sd_ble_gap_auth_key_reply is never called on the central. Because when I call dm_security_setup_req this wariant is chosen:

    if ((p_handle->device_id != DM_INVALID_ID) ||
            (m_connection_table[p_handle->connection_id].bonded_dev_id != DM_INVALID_ID))
        {
            p_handle->device_id = m_connection_table[p_handle->connection_id].bonded_dev_id;
    
            //Already bonded device, encrypt the link.
            err_code = sd_ble_gap_encrypt(m_connection_table[p_handle->connection_id].conn_handle,
                &m_bond_table[p_handle->connection_id].peer_enc_key.master_id,
                &m_bond_table[p_handle->connection_id].peer_enc_key.enc_info);
        }
    

    I found the confirmation in degug log:

    [DM]:[00]:[Block ID 0x0003F800]:Loading bond information at 20002e44, size 0x0000001C, offset 0x00000018.
    

    I thought that when i reset device or load code to flash I remove it. But it does not work. How can I do it?

Related