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

ble_app_uart_c dongle with passkey

Hi all,

I seek an advice on the passkey topic. Have been researching the topic all day but still have some confusion. I am running SDK 10.0 ble_app_uart example on nRF51 DK and ble_app_uart_c on the nRF51 dongle. The dongle connects to windows app that receives/transmit messages.

I have tried the SDK 8.0 uart example (it isn't implementing device manager) on peripheral nRF51 DK and demonstrated that adding the passkey works either with mobile phone or dongle via MCP.

Now, I want to be able to with dongle (ble_app_uart_c - SDK 10.0) send passkey via uart to peripheral device when requested. Similar to this topic here What do I need to implement in dongle?

Is device manager required (recommended) for both devices? I am confused with BLE_GAP_EVT_SEC_PARAMS_REQUEST and sd_ble_gap_sec_params_reply() on dongle side.

  • Yes. It is a lot to take. I have only seen example with device manager and I don't know how to initialise security parameters without it. It seems to be simple but every time I attempt it I get lost.

    For eample: do I need to use "ble_gap_sec_params_t m_sec_params;" and "sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &ble_opt);" to start with?

    What do I need to change to request passkey on connection and not on bonding?

  • When you want the central to pair you call sd_ble_gap_authenticate(). It takes two arguments, the connection handle and a ble_gap_sec_params_t struct. If you want to pair and set that you have a keyboard you fill the struct with something like this:

    ble_gap_sec_params_t sec_param;
    memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
    
    sec_param.bond = false;
    sec_param.mitm = false;
    sec_param.lesc = 0;
    sec_param.keypress = 0;
    sec_param.io_caps = BLE_GAP_IO_CAPS_KEYBOARD_ONLY;
    sec_param.oob = false;
    sec_param.min_key_size = 7;
    sec_param.max_key_size = 16;
    sec_param.kdist_own.enc = 0;
    sec_param.kdist_own.id = 0;
    sec_param.kdist_peer.enc = 0;
    sec_param.kdist_peer.id = 0;
    
  • Then you will get the BLE_GAP_EVT_SEC_PARAMS_REQUEST event. Since you are only pairing, you can reply with sd_ble_gap_sec_params_reply(uint16_t conn_handle, BLE_GAP_SEC_STATUS_SUCCESS, NULL, NULL); Then you will get the BLE_GAP_EVT_AUTH_KEY_REQUEST event and so on...

Related