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

Get resolvable private address on Android app when CONFIG_BT_PRIVACY=y configuration is used

Hello,

I am in a project using nRF52 board where I develop and Android app.

The application is using Android stock BLuetoothLeScanner to scan for devices. After that the app is using the BluetoothDevice instance returned by the BluetoothLeScanner to connect an then perform some reading and writing requests. Since the read and write require security then device implemented the just-works bonding so the application is bonding immediately. So the app can successfully scan, connect, bond, read and write.

The app is also implemented in that way that when performing a BLE scan for a new device, I am filtering out all devices which are already connected using the bluetooth address or the already connected devices.

My colleague from FW side just added recently the following configuration on the FW side: CONFIG_BT_PRIVACY=y.

After this change, the bluetooth address keeps changing so whenever the application is performing a BLE scan for a new device, the currently connected devices are discovered since they have a different bluetooth address.

Is there any way for the Android app to resolve the resolvable private address when the FW side is using CONFIG_BT_PRIVACY=y configuration?

If not, is there any other way I can make this work?

I would like to mention also that, in the Android application, I am using Android-BLE-Library developed by Nordic (github.com/.../Android-BLE-Library).

Thank you!

  • Hi Cornel, 

    As you may already know when you turn on the CONFIG_BT_PRIVACY=y, the peripheral will advertise using random resolvable address. This address can be resolved using an IRK key. 
    Usually the central would be able to recognize the peripheral even if the peripheral change the address, if they have bonded before and the IRK key of the peripheral is exchanged to the central. This is called whitelisting. 

    But in your case you are doing the opposite, correct ? You want to avoid reconnect to the peripheral that you already bonded before. 

    I'm not an expert in Android app development, but if you can scan and detect the device in the whitelist (address resolved), you can update it current address and avoid connecting to it. 

    If getting active whitelisted device is not possible, you may need to think about having some extra data in the advertising packet that you can use to recognize if a device is connected to the phone prior or not. Or find away to send the IRK of the device to the app on the phone (after bonding) then the app can use the IRK to resolve the address on the app and can detect if it has connected to such peripheral before or not. 

  • Hi Hung,

    Thank you for answering.

    In the application we keep an internal list of the already bonded devices so the app can easy re-connect to them.

    Also in the application we have a wizard to "onboard" new devices.

    So whenever when the app is scanning for BLE devices, the devices already bonded are found by the Android LE scanner as new devices with different bluetooth address. In this case the app will wrongly try to "onboard" an already bonded device.

    So this is what I want: a way to detect that the devices found by Android LE scanner are already bonded so to skip them and allow new devices to "onboard".

    I am afraid that there is no way in Android app development APIs to resolve the resolvable private address.

    Thank you!

  • Hello,

    Does your device support multiple bonding, or is removing the bond information when bonded to a new device (or to the same phone for the second time)? I thought that the device address is updated to the resolved one in case of bonded devices using resolvable address, but I never actually tried it.

    Perhaps your device, when already bonded and connected, is using random address for advertising, not a private resolvable. It would only use the IRK and resolvable when not connected and trying to reach the bonded phone. But then, when connected to it, it could start using some random addresses to allow other devices to bond to it, and therefore Android cannot resolve them. I'm not an expert on embedded, so that's more a question for Hung. What is the default behavior in this case in our SDKs?

    I can try to experiment with scanning for bonded devices using resolvable address and check which address is given to apps. Answering your question, there's no any API on Android that could resolve the address for you if that does not work out of the box.

  • Hello Aleksander,

    I can try to experiment with scanning for bonded devices using resolvable address and check which address is given to apps

    That would be great to get more info about it.

    Answering your question, there's no any API on Android that could resolve the address for you if that does not work out of the box.

    Thanks a lot for confirmation.

Related