1
votes

I'm new to BLE and thus BLE on Android and I'm trying to understand how BLE addresses are managed by Android. Looking at different posts and android documentation, I understood that Android is enforcing LE privacy by using private resolvable addresses when advertising and scanning.

I have a use case with challenging timing constraints and ideally I'd like to perform a direct BLE connection between 2 Android devices by using their MAC addresses instead of doing the usual scanning/advertising discovery. Unfortunately, Android is now blocking access to the current device address using BluetoothAdapter.getAddress() for privacy reasons which prevents any out-of-band flow to share BLE addresses.

I was wondering if there is any way for an Android central device to use the Bluetooth public address (the one displayed in the device settings i.e. Settings/ About Phone / Bluetooth address) of an Android device set in peripheral mode?

I tried to use the following flow without success so my guess is that it's not possible:

On Peripheral device:

  • Find the BT public address in the device settings
  • Start a GATT server
  • Start advertising with a specific UUID. This will use a new BLE private address but will not be used by the central device. This is mainly to set the device in peripheral/advertising mode.

On Central device:

  • Direct connection with the peripheral public address:
    BluetoothDevice bleDevice = mbtAdapter.getRemoteDevice(peripheralStaticPublicAddress);
    connectGATT(bleDevice, context);

Thanks for your help!

EDIT 1: I tried to use the system permission android.permission.LOCAL_MAC_ADDRESS since my device is rooted. I can get the peripheral's own public address using the BluetoothAdapter.getAddress() method but opening a GATT connection to this address on the central device does not seem to work (with or without advertising on the peripheral device).

1

1 Answers

0
votes

Only if the central supports "resolving list" (i.e. in practice is not too old) and the devices are bonded, you should be able to use the peripheral's public address (which is stored in the bonding entry as Identity Address together with the Identity Resolving Key) to connect to it. The remote device must advertise.