Static passkey - central and peripheral code issues (NCS connect)

Good morning everyone,

I am going crazy to solve this problem, but I hope we can figure it out with some help.

I am working on a prototype for which we need to use a static passkey (we know the security risks and that this is strongly discouraged, so please let's not focus on this point).

We are working with two nrf52833 boards and with NCS 2.3.0, and the code used as a starting point is the UART (for both roles).

On the peripheral side, I am able to correctly configure the board, so that when I try to connect with the NRF Connect app from my smartphone, the static passkey

is asked, and upon correct insertion of the password, the devices are bonded correctly.

I am unable to obtain the same behavior on the central.

The point where I am stuck is that apparently, after getting connected, the central invokes the bt_conn_set_security command, and I got the following error on the central

[00:00:04.986,694] .[1;31m<err> bt_smp: pairing failed (peer reason 0x8).[0m
[00:00:04.987,304] .[1;33m<wrn> ebrain_uart_bridge_central: Security failed: FA:51:0B:6F:06:18 (random) level 1 err 9.[0m
[00:00:04.987,701] .[1;33m<wrn> ebrain_uart_bridge_central: Pairing failed conn: FA:51:0B:6F:06:18 (random), reason 9.[0m

and at the same time on the peripheral I get the following error message

[00:00:09.587,799] .[1;33m<wrn> bt_smp: Unexpected SMP code 0x01.[0m

I defined in the prj.conf file the options

CONFIG_BT_SMP=y

CONFIG_BT_FIXED_PASSKEY=y

and I tried several combinations of the callbacks indicated in the forum, the last one being

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.passkey_entry = passkey_entry,
	.cancel = auth_cancel,
};

static struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed,
};

but I do not seem to find a solution....

Is anyone able to provide a complete example (especially for the central side) where a static passkey is succesfully transmitted from the central to the peripheral?

Thanks in advance for your help!

Lorenzo

Parents Reply Children
  • I tried, but anything other than BT_SECURITY_L1 gives the same errors.

    My impression is that the peripheral awaits for some information that is not sent to it.....

  • If the peripheral works with the phone, then the problem here is the central.

    Are you sure the central actually support security? What does the prj.conf look like?

  • What conn_auth_callbacks and conn_auth_info_callbacks have you set on the central?

    Edit: Never mind, I can see those above.

    Kenneth

  • Yes, this is what I think too....

    This is my prj.conf file

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    
    # Enable the BLE stack with GATT Client configuration
    CONFIG_BT=y
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_GATT_CLIENT=y
    
    # Enable the BLE modules from NCS
    CONFIG_BT_NUS_CLIENT=y
    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=n
    CONFIG_BT_GATT_DM=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    CONFIG_BT_SMP=y
    CONFIG_BT_FIXED_PASSKEY=y
    
    
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=y
    
    CONFIG_BT_LOG_LEVEL_OFF=y
    
    CONFIG_ASSERT=y
    
    
    

  • I can see you have CONFIG_BT_FIXED_PASSKEY=y, you should not need that. Since that will be handled by: For the device with passkey entry you will need to register a .passkey_entry callback in conn_auth_callbacks, make sure to call bt_conn_auth_passkey_entry(with 123456) in the callback.

    Can you try without?

    Kenneth 

Related