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

Passkey preshared key legacy pairing : Unable to connect on NRF Connect Android

Hi Guys,

I have implemented passkey legacy security pairing ( no bonding ) on my device, and i want to pair with my Android phone.

I have no keyboard/ display on my device, so i have used the sd_ble_opt_set() function to set a static passkey.

I use the peer manager to handle it.

Its configuration is :

static uint8_t key_passkey_auth[] = "012345"; 
static uint16_t key_passkey_auth_length = 6;            
static ble_opt_t passkey_opt;                          

static void peer_manager_init(void)
{
    ble_gap_sec_params_t sec_param;
    ret_code_t           err_code;

    err_code = pm_init();
    APP_ERROR_CHECK(err_code);

    //delete the previous peers
    pm_peers_delete();

    memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));

    // Security parameters to be used for all security procedures.
    sec_param.bond           = 0;
    sec_param.mitm           = 1;
    sec_param.lesc           = 0;
    sec_param.keypress       = 0;
    sec_param.io_caps        = BLE_GAP_IO_CAPS_DISPLAY_ONLY;
    sec_param.oob            = 0;
    sec_param.min_key_size   = 7;
    sec_param.max_key_size   = 16;
    sec_param.kdist_own.enc  = 0; //no long term key
    sec_param.kdist_own.id   = 0; // no resolvable address irk
    sec_param.kdist_peer.enc = 0; //no long term key
    sec_param.kdist_peer.id  = 0; // no resolvable address irk

    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);

    memset( &passkey_opt, 0, sizeof( passkey_opt ) );
    passkey_opt.gap_opt.passkey.p_passkey = key_passkey_auth;
    err_code = sd_ble_opt_set( BLE_GAP_OPT_PASSKEY, &passkey_opt );
    APP_ERROR_CHECK(err_code);
}

When I try to connect with my Android Phone, with NRF Connect, a popup appears and ask me if i want to pair with my device.

So i said yes, it appears a second time, i said yes too, and after it shows me that my device is bonded.

But I have no entered my passkey, and when i try to read a secured characteristic, i have nothing.

I have read a lot of thread about this subject, but i haven't found the solution to my problem.

Related