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
  • 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
    
    
    

Children
Related