BLE pairing issue when BT_SECURITY_L4 with nRF5340

Hi,

I'm having the same problem as in:

BLE pairing issue when BT_SECURITY_L4 with nRF5340 - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)

I would also like to ask for a kind of general "recipe" that always works to recover if the Bluetooth stack is stuck somewhere.

The goal would be to remove all left overs from previous connections and to make it possible to start scanning again

for devices that are advertising.

Kind regards,

Arno

Parents
  • Hello,

    Is the reason for this that the connected device has bonding information about your device stored? Or vice versa? To check, if you delete bonding information on both sides, does the issue go away? If you are not sure how to delete bonding information, please let me know. And if that was in fact the case, which device had old bonding data stored, and which one did not?

    Best regards,

    Edvin

  • Hi,

    I'm basically using the central and peripheral uart example with nRF Connect SDK 2.3.0.

    I have cleared the bonding information in the following way on the peripheral uart device:


                // To notify the central to remove the pairing, pairing has to be removed
                // on both sides, this seems the only way to notify the central and to
                // remove the pairing.
                int err = bt_conn_disconnect(current_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
                // int err = bt_conn_disconnect(current_conn, BT_HCI_ERR_PAIRING_NOT_ALLOWED);
                printk("button_changed(): bt_conn_disconnect()=%d called\n", err);

                err = bt_unpair(BT_ID_DEFAULT, BT_ADDR_LE_ANY);
                printk("button_changed(): bt_unpair=%d\n", err);

                // Stop the advertising, take this device out of the air
                err = bt_le_adv_stop();
                printk("button_changed(): bt_le_adv_stop=%d\n", err);

                // Now really stop everything, sadly this is not supported
                err = bt_disable();
                printk("button_changed(): bt_disable=%d, -134==ENOTSUP\n", err);

     I have cleared the bonding information on the central uart device as follows in the connected() routine:

        // BT_HCI_ERR_REMOTE_USER_TERM_CONN is a normal termination from the peripheral
        // BT_HCI_ERR_PAIRING_NOT_ALLOWED is not usable, does not work on peripheral side
        if (reason == BT_HCI_ERR_REMOTE_USER_TERM_CONN)
        {
            // The peripheral has disconnected, we use this to unpair
            int err = bt_unpair(BT_ID_DEFAULT, BT_ADDR_LE_ANY);
            printk("disconnected: bt_unpair=%d\n", err);
        }

        err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
        printk("disconnected: bt_scan_start=%d\n", err);
        if (err)
        {
            printk("disconnected: Scanning failed to start (err %d)\n",
                   err);
        }

    Please inform me whether this is the correct way to remove the bonding information. To my knowledge unpair()

    should be enough, or are there other ways?

    Any help greatly appreciated,

    Arno

Reply
  • Hi,

    I'm basically using the central and peripheral uart example with nRF Connect SDK 2.3.0.

    I have cleared the bonding information in the following way on the peripheral uart device:


                // To notify the central to remove the pairing, pairing has to be removed
                // on both sides, this seems the only way to notify the central and to
                // remove the pairing.
                int err = bt_conn_disconnect(current_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
                // int err = bt_conn_disconnect(current_conn, BT_HCI_ERR_PAIRING_NOT_ALLOWED);
                printk("button_changed(): bt_conn_disconnect()=%d called\n", err);

                err = bt_unpair(BT_ID_DEFAULT, BT_ADDR_LE_ANY);
                printk("button_changed(): bt_unpair=%d\n", err);

                // Stop the advertising, take this device out of the air
                err = bt_le_adv_stop();
                printk("button_changed(): bt_le_adv_stop=%d\n", err);

                // Now really stop everything, sadly this is not supported
                err = bt_disable();
                printk("button_changed(): bt_disable=%d, -134==ENOTSUP\n", err);

     I have cleared the bonding information on the central uart device as follows in the connected() routine:

        // BT_HCI_ERR_REMOTE_USER_TERM_CONN is a normal termination from the peripheral
        // BT_HCI_ERR_PAIRING_NOT_ALLOWED is not usable, does not work on peripheral side
        if (reason == BT_HCI_ERR_REMOTE_USER_TERM_CONN)
        {
            // The peripheral has disconnected, we use this to unpair
            int err = bt_unpair(BT_ID_DEFAULT, BT_ADDR_LE_ANY);
            printk("disconnected: bt_unpair=%d\n", err);
        }

        err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
        printk("disconnected: bt_scan_start=%d\n", err);
        if (err)
        {
            printk("disconnected: Scanning failed to start (err %d)\n",
                   err);
        }

    Please inform me whether this is the correct way to remove the bonding information. To my knowledge unpair()

    should be enough, or are there other ways?

    Any help greatly appreciated,

    Arno

Children
No Data
Related