Florian Echtler
Florian Echtler

Reputation: 2513

Android 4.3 not showing Bluetooth Low Energy advertisements

I'm experimenting with a Bluetooth LE device which just sends advertisements (similar to the iBeacon). On my Linux machine, "hcitool lescan" detects the device being advertised and shows the "shortened name", so the over-the-air interface seems to be working correctly.

Unfortunately, on my Nexus 4 phone with latest stock ROM (Android 4.3), I've tried 4 different Bluetooth LE scanner apps, and none of them show the device's advertisements. However, when the device is active, "adb logcat" shows lots of btu_ble_process_adv_pkt [1] events being handled, which does stop as soon as the device is powered down. So obviously the BTLE stack seems to be picking up my advertisements, but they don't reach the apps.

Can anyone advise on what fields advertisements must contain to be properly handled by Android?

[1] https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/jb-mr1.1-dev/stack/btu/btu_hcif.c#2198

Upvotes: 3

Views: 1168

Answers (1)

Florian Echtler
Florian Echtler

Reputation: 2513

I managed to figure it out myself: if you have a BTLE device which only sends advertisements and doesn't accept any connections, then you have to make sure that the PDU type sent as the very first byte of the message is 0x02 (ADV_NONCONN_IND). Otherwise, Android will apparently try to open a connection in order to query GATT attributes, which of course fails. AFAICT, iOS is more tolerant here.

Upvotes: 2

Related Questions