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

Setting a PASSKEY

Hello! I am trying to develop on the nRF51822 eval board as called PCA10001. The programming interface I use is uVision4 on win7.

I would set a static PASSKEY for the pairing process in the reference code "ble_app_hrs". I add "sd_ble_gap_authenticate(p_ble_evt->evt.gap_evt.conn_handle,&m_sec_params)" at the top of "ble_evt_dispatch(ble_evt_t * p_ble_evt)". The PASSKEY has been set as "111111" in (p_ble_evt->evt.gap_evt.params.passkey_display.passkey[i]= '1').

As the result, in running "Heart Rate Monitor" in "nRF Utility APP", the screen pops up a pairing request. When I select "Pairing",

  • the iPhone get paired to the PCA10001 without asking any PASSKEY, and
  • the heart rate will never appear again, even I reload the original "ble_app_hrs" code.

Question 1, Did I erase anything so that original "ble_app_hrs" code can not work? Question 2, what is the proper way to add the PASSKEY for the pairing? Question 3, I assume "intern_ble_stack_events_execute(.......)" will be directed to "ble_evt_dispatch(....)" when the BLE stack event received. Is it applicable in this case?

Thanks for help. ELCA

  • Just to say that you cannot have static PASSKEY and next are the answers:

    Question 1, Did I erase anything so that original "ble_app_hrs" code can not work?

    Example does use: #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ So device does not have capabilities for entering PASSKEY, in this case another association model is used.

    Question 2, what is the proper way to add the PASSKEY for the pairing? This depends on your device capabilities, in other words does it has keyboard.

    #define BLE_GAP_IO_CAPS_DISPLAY_ONLY      0x00   /**< Display Only. */
    #define BLE_GAP_IO_CAPS_DISPLAY_YESNO     0x01   /**< Display and Yes/No entry. */
    #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY     0x02   /**< Keyboard Only. */
    #define BLE_GAP_IO_CAPS_NONE              0x03   /**< No I/O capabilities. */
    #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY  0x04   /**< Keyboard and Display. */
    

    Question 3: Check the ble_app_gls example from documentation.

  • As Mihail pointed out, the IO capability flags are used to specify how the user can interface with the peripheral. If the peripheral has a numerical keyboard a 6-digit passkey can be used in the pairing process. The passkey is typically generated randomly and displayed on the Central device (iPhone), and the user has to enter the passkey on the Peripheral device. If the keys match, the pairing process succeeds.

    For devices without any displays/keyboards/buttons, "Just Works" encryption is used in the pairing process. This is basically pairing with a static key.

    By setting IO capabilities to BLE_GAP_IO_CAPS_NONE the iPhone won't ask for a passkey to be entered. However, if you want to use passkey in your application, you can for example use the UART to enter the passkey on your connected PC and transmit the passkey to the PCA10001.

    Note that it's up to the application to read user input and notify the SoftDevice (see sd_ble_gap_auth_key_reply())

Related