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

static passkey s132

Hi,

I've allready read a lot about using a static passkey on the DevZone and I have tried tons of things, but I just can't get it to work.

What I want is to connect to my BLE peripheral, a NRF52832 with the S132 softdefice from an Android phone (using the nRF Connect app). I want to make sure that some services and characteristics can only be read or written when a password is entered.

In the most ideal way that would mean that in order to connect the user has to enter a predefined passkey (i.e. 123456). Only if the passkey is correct the user should be able to connect to the device.

I found that the term 'connect' is quite vague in BLE as there are 3 types, namely connecting, pairing and bonding. I don't know at what stage the user should enter a password but I'm guessing it is at bonding stage.

I tried to set a static passkey in the softdevice using this code:

// Set the static passkey for pairing
static_pin_option.gap_opt.passkey.p_passkey = static_passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &static_pin_option);
APP_ERROR_CHECK(err_code);

Here the static_passkey is defined globally:

static uint8_t static_passkey[] = STATIC_PASSKEY;

where STATIC_PASSKEY is:

#define STATIC_PASSKEY					"123456"

This does not work as my Android phone can connect and bond to the device without entering the password, it is never prompted.

Can someone please help me out with this, I dont know what is the right way to go. Thanks :)

Parents
  • Connect is connect, after you have connected you can pair and optionally bond.

    Have you set that you want to bond, and that you require MITM protection?

    #define SEC_PARAM_BOND                 1                                           /**< Perform bonding. */
    #define SEC_PARAM_MITM                 1                                           /**< Man In The Middle protection required. */
    

    Have you set the IO capabilites to display only?

    #define SEC_PARAM_IO_CAPABILITIES      BLE_GAP_IO_CAPS_DISPLAY_ONLY                /**< Display I/O capabilities. */
    
Reply
  • Connect is connect, after you have connected you can pair and optionally bond.

    Have you set that you want to bond, and that you require MITM protection?

    #define SEC_PARAM_BOND                 1                                           /**< Perform bonding. */
    #define SEC_PARAM_MITM                 1                                           /**< Man In The Middle protection required. */
    

    Have you set the IO capabilites to display only?

    #define SEC_PARAM_IO_CAPABILITIES      BLE_GAP_IO_CAPS_DISPLAY_ONLY                /**< Display I/O capabilities. */
    
Children
No Data
Related