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

Cannot set bt_conn_set_security to BT_SECURITY_L4

I'm evaluating nRF52840 DK.

Currently running peripheral_lbs example.

I'm trying to set security level to BT_SECURITY_L4

static void connected(struct bt_conn *conn, uint8_t err)
{
	if (err) {
		printk("Connection failed (err %u)\n", err);
		return;
	}

	printk("Connected\n");

    int sec_result = bt_conn_set_security(conn, BT_SECURITY_L4);
    printk("Cannot set security level, err %d\n", sec_result);
          
	dk_set_led_on(CON_STATUS_LED);
}

I'm connecting to nRF52840DK with via smartphone nRFConnect app, then I enter pin code, but connection fails.

bt_conn_set_security returns 0 (SUCCESS)

These lines are output to console:

Passkey for d0:1d:c1:85:77:9b (random): 786779
[00:00:12.933,227] [1;31m<err> bt_hci_core: Failed to set required security level
[00:00:12.941,314] [1;31m<err> bt_conn: not connected
[00:00:12.946,960] [1;31m<err> bt_conn: not connected
Security changed: d0:1d:c1:85:77:9b (random) level 3
Disconnected (reason 22)

Setting security levels to BT_SECURITY_L2 or BT_SECURITY_L3 works.

Parents
  • Hi,

    I got level 4 with peripheral_lbs example in NCS 1.4.1. Is it possible that you phone may not be supporting LESC pairing and only legacy pairing? LESC is required to reach level 4. If you are not sure, you could capture a sniffer trace (nRF Sniffer for Bluetooth LE) to confirm whether it is supported or not.

    Connected
    Passkey for 4d:92:d5:4b:82:2a (random): 792560
    Security changed: 4d:92:d5:4b:82:2a (random) level 4
    Pairing completed: 6c:dd:bc:29:d8:8e (public), bonded: 1

    Best regards,

    Vidar

  • Looks like that is sthe case. I have Samsung Galaxy J2, whis has only bluetooth 4.1

    I tried with another android phone and it connected succesfully,

    Then, there is another question:

    The "secuirity_changed" callback, which is called. Then immediately "disconnected" callback.

    But callbacks from "bt_conn_auth_cb" are not executed.

    Shouldn't the bt_conn_auth_cb.cancel or bt_conn_auth_cb.pairing_failed callbacks be executed?

Reply
  • Looks like that is sthe case. I have Samsung Galaxy J2, whis has only bluetooth 4.1

    I tried with another android phone and it connected succesfully,

    Then, there is another question:

    The "secuirity_changed" callback, which is called. Then immediately "disconnected" callback.

    But callbacks from "bt_conn_auth_cb" are not executed.

    Shouldn't the bt_conn_auth_cb.cancel or bt_conn_auth_cb.pairing_failed callbacks be executed?

Children
Related