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

Bonding after pairing for "ble_app_multirole_lesc"

I have a question about the sample project "ble_app_multirole_lesc (SDK V15.3.0)".

I set the following parameters to perform pairing without bonding.


////////////////////////////////////////////////////////////////////////////////////////
// Security parameters to be used for all security procedures.
sec_params.bond = 0;
sec_params.mitm = 0;
sec_params.lesc = 1;
sec_params.keypress = 0;
sec_params.io_caps = BLE_GAP_IO_CAPS_NONE;
sec_params.oob = 0;
sec_params.min_key_size = 7;
sec_params.max_key_size = 16;
sec_params.kdist_own.enc = 0;
sec_params.kdist_own.id = 0;
sec_params.kdist_peer.enc = 0;
sec_params.kdist_peer.id = 0;

err_code = pm_sec_params_set(&sec_params);
APP_ERROR_CHECK(err_code);
////////////////////////////////////////////////////////////////////////////////////////


Is it possible to manually bond after pairing is confirmed?
Also, please let me know how.

Parents
  • Hi,

    Yes, call pm_sec_params_set() with the new security parameters, and after that call pm_conn_secure() to start the bonding procedure.

  • Hi,

    When I tried it, an error occurred after the "PM_EVT_CONN_SEC_PARAMS_REQ" event occurred.
    After that, the connection is disconnected and bonding is not completed.
    Looks like the security procedure is starting over.

    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x2, procedure: Encryption, error: 4102

    Please tell me the cause and measures.

  • Could you add the whole log, from startup until the error occurs ? Could you also check the security status of the link before calling pm_conn_secure(), using pm_conn_sec_status_get() ?

  • The log is shown below.
    I tried calling pm_conn_sec_status_get, but encryption seems to be established.

    <info> app: LE Secure Connections example started.
    <info> app: Scanning
    <info> app: Advertising
    <info> app: PERIPHERAL: Connected, handle 1.
    <info> app: PERIPHERAL: BLE_GAP_EVT_SEC_PARAMS_REQUEST
    <info> app: PERIPHERAL: BLE_GAP_EVT_LESC_DHKEY_REQUEST
    <info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 1
    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 1, procedure: Pairing
    <info> app: PERIPHERAL: BLE_GAP_EVT_AUTH_STATUS: status = 0x0 bond = 0x0 lv4: 0 kdist_own: 0x0 kdist_peer: 0x0
    <info> app: Peer param to bond
    <info> app: [pm_conn_sec_status_get] connected = 1, encrypted = 1, mitm_protected = 0, bonded = 0
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x1, procedure: Encryption, error: 4102
    <warning> peer_manager_handler: Disconnecting conn_handle 1.
    <info> app: PERIPHERAL: Disconnected, handle 1, reason 0x16.

  • Try to delete any previous bond information you might have stored on the phone for this device. (See this post regarding error 4102).

    Also, what security parameters are you using when you call pm_conn_secure() the second time ?

  • The parameters for calling pm_conn_secure () after the second time are shown below.

    sec_params.bond = 1;
    sec_params.mitm = 0;
    sec_params.lesc = 1;
    sec_params.keypress = 0;
    sec_params.io_caps = BLE_GAP_IO_CAPS_NONE;
    sec_params.oob = 0;
    sec_params.min_key_size = 7;
    sec_params.max_key_size = 16;
    sec_params.kdist_own.enc = 1;
    sec_params.kdist_own.id = 1;
    sec_params.kdist_peer.enc = 1;
    sec_params.kdist_peer.id = 1;

    err_code = pm_sec_params_set (& sec_params);
    APP_ERROR_CHECK (err_code);

  • An attempt to delete previous bond information that may have been stored on the phone of this device was disconnected.
    I am using "nRF Connect".
    After "Connect", "Delete bond information" was performed.
    Is the method wrong?
    The log when disconnected is shown below.

    <info> app: LE Secure Connections example started.
    <info> app: Erase bonds!
    <info> peer_manager_handler: All peers deleted.
    <info> app: Scanning
    <info> app: Advertising
    <info> app: PERIPHERAL: Connected, handle 1.
    <info> app: PERIPHERAL: BLE_GAP_EVT_SEC_PARAMS_REQUEST
    <info> app: PERIPHERAL: BLE_GAP_EVT_LESC_DHKEY_REQUEST
    <info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 1
    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 1, procedure: Pairing
    <info> app: PERIPHERAL: BLE_GAP_EVT_AUTH_STATUS: status=0x0 bond=0x0 lv4: 0 kdist_own:0x0 kdist_peer:0x0
    <info> app: PERIPHERAL: Disconnected, handle 1, reason 0x13.

Reply
  • An attempt to delete previous bond information that may have been stored on the phone of this device was disconnected.
    I am using "nRF Connect".
    After "Connect", "Delete bond information" was performed.
    Is the method wrong?
    The log when disconnected is shown below.

    <info> app: LE Secure Connections example started.
    <info> app: Erase bonds!
    <info> peer_manager_handler: All peers deleted.
    <info> app: Scanning
    <info> app: Advertising
    <info> app: PERIPHERAL: Connected, handle 1.
    <info> app: PERIPHERAL: BLE_GAP_EVT_SEC_PARAMS_REQUEST
    <info> app: PERIPHERAL: BLE_GAP_EVT_LESC_DHKEY_REQUEST
    <info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 1
    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 1, procedure: Pairing
    <info> app: PERIPHERAL: BLE_GAP_EVT_AUTH_STATUS: status=0x0 bond=0x0 lv4: 0 kdist_own:0x0 kdist_peer:0x0
    <info> app: PERIPHERAL: Disconnected, handle 1, reason 0x13.

Children
Related