[nRF Connect SDK]Force to make pairing(bonding)

Target nRF52832(nrf52dk_nrf52832)
SDK NCS v2.0.0

I'm testing NCS 2.0 with Android 12.

Making pairing with Android, I call two API when connected.

bt_set_bondable(true);
bt_conn_set_security(conn, BT_SECURITY_L4);

It worked well so far (under Android 11)

BTW Android 12 make trouble security level 1 error.


[log]
00> HS connected
00> HS Connected 4A:B4:CA:22:85:2D (random)
00> Connection parameters updated.
00> interval: 6, latency: 0, timeout: 500
00> Conn params updated: interval 7 ms, latency 0, timeout: 5000 ms
00> Security failed: 4A:B4:CA:22:85:2D (random) level 1 err 2
00> Disconnected: 4A:B4:CA:22:85:2D (random) (reason 34)

Can I have another option to make pairing automatically?

  • I changed it as 'n'
    I'll make log and update it with peripheral_uart sample when ready.

  • Hmm.. I can see that the peripheral still send the security request on connection. My main goal at the moment is to get a sniffer log without the security request I see in the start of the log files:

    Can you comment out bt_conn_set_security() and see if that impact the issue?

    Ideally bt_conn_set_security() should not be sent upon connection establishment, but instead sent after some seconds if the link is not been encrypted already.

    Kenneth

  • 1. In my test, there was no pairing without bt_conn_set_security().

    2. Although 
    CONFIG_BT_GATT_AUTO_SEC_REQ=n is set, pairing will be initiated from BLE, right?

    In Korea, we will have national holiday by end of this week. I'll be back next Monday.

    Thank you.

     

  • Hi again,

    I suggest to keep CONFIG_BT_GATT_AUTO_SEC_REQ=n, but I recommend that you try to look into a way to delay calling the bt_conn_set_security().

    Don't call bt_conn_set_security() on connected() callback, but start it for instance after 100ms after connected() callback or (for test) just use a button to call bt_conn_set_security() after connection is established.

    I do believe that the issue is that android here for some unknown reason have problem handling the security request that it received on the first connection event, I have seen this can be problematic before, so a adding a delay should help.

    From the on-air sniffer I can find a lot of data is missing, so if possible try to move phone, device and sniffer closer together to ensure that the sniffer log is more complete.

    Looking at your latest log I have written in red text a bit more what the errors mean, but difficult to know exactly how to interpret this without a more complete log:

    00> [00:03:14.597,900] <inf> peripheral_uart: ##Connected 00:16:7F:3F:B3:AD (public)
    00> [00:03:24.661,376] <wrn> peripheral_uart: Security failed: 00:16:7F:3F:B3:AD (public) level 1 err 9 - BT_SECURITY_L1 BT_SECURITY_ERR_UNSPECIFIED
    00> [00:03:24.662,719] <inf> peripheral_uart: Disconnected: 00:16:7F:3F:B3:AD (public) (reason 40) - BLE_HCI_INSTANT_PASSED

    Best regards,
    Kenneth

Related