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

Use LESC in just works for the ble_thread_dyn_mtd_coap_cli_nfc exemple

Hello

I would like to modify the example "ble_thread_dyn_mtd_coap_cli_nfc" to use Just Works pairing instead of OOB with NFC.

To do this, I modified this in sdk_config.h:
#define NFC_BLE_PAIR_LIB_ENABLED 0
#define NFC_PAIRING_MODE 2

I added this in main.c:

/**@brief Function for handling Peer Manager events.
 *
 * @param[in] p_evt  Peer Manager event.
 */
static void pm_evt_handler(pm_evt_t const * p_evt)
{
    pm_handler_on_pm_evt(p_evt);
    pm_handler_flash_clean(p_evt);
}

/**@brief Function for the Peer Manager initialization.
 *
 * @param[in] erase_bonds  This flag informs if existing bonds should be erased.
 */
void peer_manager_init(bool erase_bonds)
{
    ble_gap_sec_params_t sec_param;
    ret_code_t err_code;

    err_code = pm_init();
    APP_ERROR_CHECK(err_code);

    if (erase_bonds)
    {
        err_code = pm_peers_delete();
        APP_ERROR_CHECK(err_code);
    }
    memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
    // Security parameters to be used for all security procedures.
    sec_param.bond = false;//true;
    sec_param.mitm = false;
    sec_param.lesc = 1;
    sec_param.keypress = 0;
    sec_param.io_caps = BLE_GAP_IO_CAPS_NONE;
    sec_param.oob = false;
    sec_param.min_key_size = 7;
    sec_param.max_key_size = 16;
    sec_param.kdist_own.enc = 0;//1;
    sec_param.kdist_own.id = 0;//1;
    sec_param.kdist_peer.enc = 0;//1;
    sec_param.kdist_peer.id = 0;//1;

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

    err_code = pm_register(pm_evt_handler);
    APP_ERROR_CHECK(err_code);
}

And I added this in the while(true) of the main():

err_code = nrf_ble_lesc_request_handler();
APP_ERROR_CHECK(err_code);

I think I forgot something because I can connect but there is no pairing. Do you know why ?
I notice that sometimes it is indicated in the code that pairing is not supported: is this related to my problem?



Thank you

Parents Reply
  • Hi Amanda,

    For example, if I modify the "ble_app_multirole_lesc" example to have a connection that uses LESC in "just works" without bonding (sec_param.bond = false) as presented above, I receive 2 pairing messages on my Samsung S10 to ask me if I want to pair myself. But I find that I don't have this problem if I run the test on my S7.

    Android Version on my S7: 8.0.0
    Android Version on my S10: 11

Children
Related