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

The nRF52 bonded device is automatically unbonded when the Android phone is rebooted.

Hello!

I am developing an application which is connecting to an nRF52 board using the Android-BLE-Library implemented by Nordic
The application is doing the following:

  1. Perform an LE scan using Google's recommended Android stock class, which is BluetoothLeScanner, to scan for the board -> as a result the nRF52 board is found by the BluetoothLeScanner
  2. The app is sending a connect request to the nRF52 board -> as a result it successfully connects
  3. Then the application performs a write with response request to a characterisc which require bonding - in my case I am performing a write request to enable the indications on a secure characteristic
  4. Since it is a secure writing, and the board is requesting bonding, the Android framework will automaticaly initiate the bonding - no code required on the Android app side to perform the bond -> as a result the bond succedes and then I get the write response back that the write completed successfully
  5. I check the bonded devices list in the Android Bluetooth setting screen and the nRF52 board is listed
  6. I reboot the phone. When the phone is rebooted I check again the Bluetooth settings screen and the nRF board is still listed

The FW team did the following changes in one monolithic commit, on the FW side:

  • in prj.conf file the following line was added: CONFIG_BT_PRIVACY=y
  • for the secure characteristics, in the BT_GATT_CHARACTERISTIC(...) the 3rd parameter was changed from BT_GATT_PERM_WRITE_AUTHEN into BT_GATT_PERM_WRITE_ENCRYPT for writing and from BT_GATT_PERM_READ_AUTHEN into BT_GATT_PERM_READ_ENCRYPT for reading
  • the initial two steps bonding with numerical confirmation was changed into one step just-works bonding
  • and some othere changes which I couldn't figure out what those means

Now it comes the problem. After these changes all the steps above where successfull except step 6 - after rebooting, the device was not listed anymore in the bonded devices list in Bluetooth settings screen. So before rebooting the device was listed, after rebooting the device was automatically unbonded.

Is it possible that any of the changes the FW team did could lead to this behaviour?
Is it possible that I am doing something wrong on the app side?

Thank you!

Parents
  • My colleague from FW side managed to narrow down the change which is reproducing the issue:

    from

    static struct bt_conn_auth_cb conn_auth_callbacks = {
    .passkey_display = auth_passkey_display,
    .passkey_entry = NULL,
    .passkey_confirm = passkey_confirm,
    .cancel = auth_cancel,
    .pairing_confirm = pairing_confirm,
    .pairing_complete = pairing_complete,
    .pairing_failed = pairing_failed,
    .bond_deleted = bond_deleted
    };

    into

    static struct bt_conn_auth_cb conn_auth_callbacks = {
    .passkey_display = NULL,
    .passkey_entry = NULL,
    .passkey_confirm = NULL,
    .cancel = auth_cancel,
    .pairing_confirm = pairing_confirm,
    .pairing_complete = pairing_complete,
    .pairing_failed = pairing_failed,
    .bond_deleted = bond_deleted
    };

    I also noticed on the Android app side: after connecting and just before sending any request to the device, if the app code runs a remote device discovery (using the function bluetoothAdapter.startDiscovery()) until the nRF52 board is discovered, then the problem is not reproducing anymore.

    Is the discovery required for the bond to be strong and not removed after phone reboots? Is the application missing something else?

    Is the FW implementation missing anything triggering the need of running a discovery to make the bond stronger?

    Thank you!

Reply
  • My colleague from FW side managed to narrow down the change which is reproducing the issue:

    from

    static struct bt_conn_auth_cb conn_auth_callbacks = {
    .passkey_display = auth_passkey_display,
    .passkey_entry = NULL,
    .passkey_confirm = passkey_confirm,
    .cancel = auth_cancel,
    .pairing_confirm = pairing_confirm,
    .pairing_complete = pairing_complete,
    .pairing_failed = pairing_failed,
    .bond_deleted = bond_deleted
    };

    into

    static struct bt_conn_auth_cb conn_auth_callbacks = {
    .passkey_display = NULL,
    .passkey_entry = NULL,
    .passkey_confirm = NULL,
    .cancel = auth_cancel,
    .pairing_confirm = pairing_confirm,
    .pairing_complete = pairing_complete,
    .pairing_failed = pairing_failed,
    .bond_deleted = bond_deleted
    };

    I also noticed on the Android app side: after connecting and just before sending any request to the device, if the app code runs a remote device discovery (using the function bluetoothAdapter.startDiscovery()) until the nRF52 board is discovered, then the problem is not reproducing anymore.

    Is the discovery required for the bond to be strong and not removed after phone reboots? Is the application missing something else?

    Is the FW implementation missing anything triggering the need of running a discovery to make the bond stronger?

    Thank you!

Children
No Data
Related