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

static passkey demo code for S110 stackV8.0/SDK10 of nrf51822

Dear all

I want to add the static pin to my project(s110 stackV8.0, based on SDK10), add the follow code to gap_params_init:

uint8_t passkey[] = STATIC_PASSKEY;
m_static_pin_option.gap_opt.passkey.p_passkey = passkey;
err_code =  sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &m_static_pin_option);

init the device manager. But it seems not work as phone can connect it successfully without type in passkey. Any link or demo code can I refer to ?

Regards Jenson

  • First - please use the code buttons to format your message so it can be read - I just fixed it for you, you get a preview at the bottom of the screen so you can edit until it's legible.

    Secondly - do you have any permissions on any of the characteristics? Anything can connect to you without requiring a passkey - it's when you try to access characteristics which require pairing/bonding that the bonding process will occur.

  • Thanks for your remind. I will follow the rules.
    But for my understanding, when we use the phone connect to the device, there should pop out an pair requirement to let phone type in passkey to complete the pair process. Right? But how to achieve this? Any demo can I refer to?

  • A peripheral will allow any central to connect to it, as long as it is not using a whitelist. You connect before you pair, you pair to increase the security level of the link so that you can access characteristic values or descriptors that require a certain security level.

    You can set the security requirement of the characteristic values and descriptors by using the GAP attribute security requirement setters, see for example in glucose_feature_char_add() where you need security level 2 (BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm);) to read the characteristic value. This question may also give some insight.

    The central device, here the smart phone, must send the pairing request. The smart phone will normally send this pairing request when it tries to access a peripheral that requires encryption without success.

  • Petter

    Thanks for your information, that helps.

    I solve this issue by followed steps:

    1. set the fixed passkey in gap_params_init see in post 1 code.
    2. init the device manager which will set the IO capabilities and call the SDK's device manager event process function.
    3. Set the characteristics' security level like: BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm);

    Regards Jenson

  • Np :) Then I would appreciate if you would accept my answer by clicking the check mark next to it. Thx.

Related