Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read the Bluetooth LE advertisement data in Android at the time of scanning

Bluetooth LE devices can broadcast messages to other devices. That message packet can include informations like length, profile, rssi (signal strength), etc.

How can I read those Bluetooth LE broadcast data when scanning for BLE devices in Android?

like image 882
vky Avatar asked Oct 04 '12 18:10

vky


1 Answers

API Levels 21+

In android.bluetooth.le.ScanCallback, the callback method as follows has a parameter named result, which has a field called scanRecord, with should contain the advertisement data sent by a BLE device.

void onScanResult (int callbackType, ScanResult result)

API Levels 18-20

In BluetoothAdapter.LeScanCallback, the callback method as follows has a parameter named scanRecord, which should contain the advertisement data sent by a BLE device.

public abstract void onLeScan (BluetoothDevice device, int rssi, byte[] scanRecord)

scanRecord: The content of the advertisement record offered by the remote device.

like image 71
Jason H Avatar answered Sep 29 '22 10:09

Jason H