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
  • Hello Kenneth, thanks for the pointer, but I already read that discussion and followed the indicated steps.

    As of now, I have in fact the peripheral working fine and accepting a static passkey sent using the smartphone app "Nrf Connect".

    My problem is when I use a nrf52833DK as a central instead of the smartphone: whatever I try, I get the errors indicated in the original post...It seems that the problems start when I call the

    	err = bt_conn_set_security(conn, BT_SECURITY_L4);
    

    which is not accepted by the peripheral....

    So, what is the central supposed to send to the peripheral? At what moment should the central send the passkey to validate its connection to the peripheral?

Children
Related