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

set PASSKEY to 4 digits

Hello,

We are using a passkey in our application and by default is 6 digits long. I have found in other posts that this is mandatory a cannot be changed.

Is it real?

the strange thing is that both iOS and Android suggest a 4 digit PIN by default when trying to pair with our device. Therefore my client is a bit annoyed that the APP suggest a 4 digits pin and he has to put a 6 digits instead.

here the snippet of the code I am using:

#define BLE_DEFAULT_PASSKEY "000000"

//set defaul passkey
uint8_t passkey[] = BLE_DEFAULT_PASSKEY;
ble_opt_t ble_opt;
ble_opt.gap_opt.passkey.p_passkey = passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &ble_opt);
APP_ERROR_CHECK(err_code);

Thanks and Regards!

  • Hi,

    We are using a passkey in our application and by default is 6 digits long. I have found in other posts that this is mandatory a cannot be changed.

    Is it real?

     Yes.

    From BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1289 , https://www.bluetooth.com/specifications/specs/core-specification/

    For Secure Simple Pairing and Security Manager, the Bluetooth passkey is a 6-
    digit numerical value.

    In BR/EDR Legacy Pairing it was possible to use a 4-digit PIN, but this is not possible with Bluetooth Low Energy.

    From BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 1, Part A page 271

    Secure Simple Pairing has two security goals: protection against passive
    eavesdropping and protection against man-in-the-middle (MITM) attacks
    (active eavesdropping). It is a goal of Secure Simple Pairing to exceed the
    maximum security level provided by the use of a 16 character, alphanumeric,
    case-sensitive PIN with BR/EDR Legacy Pairing, which often used a 4-digit
    PIN or a fixed PIN of commonly known values significantly limiting the security
    on the link.
Related