2

I have a small app which just performs a BLE Advertising. The app runs on a Nexus 5x with Android 8.0

This is the code to start BLE advertising:

private fun startAdvertising() {
    val serviceUuid = ParcelUuid.fromString("DAB5D1DC-0000-1000-8000-00805F9B34FB")

    val data = AdvertiseData.Builder()
            .setIncludeTxPowerLevel(false)
            .setIncludeDeviceName(false)
            .addServiceUuid(serviceUuid)
            .build()

    val settings = AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
            .setConnectable(true)
            .build()

    bluetoothLeAdvertiser!!.startAdvertising(settings, data, advertiserCallback)
}

The advertising starts, but the payload is wrong. On Pre-Android 8.0 devices we receive the correct service-uuid when scan for this messages with a 2nd device:

32-bit Service-UUID: 0xDAB5D1DC

But when I start the advertisements on my Nexus 5x with Android 8.0, I receive an incorrect service-uuid:

32-bit Service-UUID: 0x0000D1DC

For the BLE scanning part I use the nrf Connect app from playstore.

Everything works as expected, if I advertise a common 128-bit Service UUID and not an 32-bit one.

Are there any changes for Android 8.0 regarding my issue?

Update 2017-08-28:

Same issue on a Nexus 6P. Created an issue: https://issuetracker.google.com/issues/65099899

Christopher
  • 9,682
  • 7
  • 47
  • 76

2 Answers2

0

Use only ParcelUuid.fromString("DAB5D1DC") this will make youre packet smaller. youre problem is probably because youre advertise packet too big i think the max is 32 bytes.

Ran Sasportas
  • 2,256
  • 1
  • 14
  • 21
0

Create Constants

 public static final UUID serviceUuid = UUID.fromString("DAB5D1DC-0000-1000-8000-00805F9B34FB");

and than

 val data = AdvertiseData.Builder()
        .setIncludeTxPowerLevel(false)
        .setIncludeDeviceName(true)
        .addServiceUuid(new ParcelUuid(Constants.serviceUuid))
        .build()
TsigumEnes
  • 131
  • 1
  • 14