Share
Embed
Bluetooth LE Matures in Android Lollipop
Walkthrough of the updates and changes made to the Bluetooth LE APIs in Android 5.0+.
Dave Smith
November 18, 2014
Transcript
14 slides
-
Android Lollipop: Bluetooth LE Matures Dave Smith @devunwired 1 Get
the Examples: h.p://github.com/devunwired/accessory-samples -
GATT Profile Service <16-bit AssignedNumber> Service <UUID> GATT Peripheral 3
CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value CharacterisHc Proper&es Value -
Bluetooth UUIDs • Everything has a UUID – Adopted services
are 16-bit added to a common 128-bit base: • 00000000-0000-1000-8000-00805F9B34FB – Custom services can be any generated UUID • Example SIG UUIDs – Health Thermometer Service: 0x1809 – Link Loss Service: 0x1803 – Battery Level Characteristic: 0x2A19 – Date Time Characteristic: 0x2A08 • Full Thermometer UUID – 00001809-0000-1000-8000-00805F9B34FB 4 -
Lollipop Scanning Improvements 5 Scans: Filter AdverHsed Service UUIDs Scans:
Filter on ANY AdverHsed Field Receive Single Device AdverHsement per Scan Receive All AdverHsements during a Scan Manual Scan Record Parsing ScanRecord & AdverHseData + Builders AcHve Scanning Only Scan Result Batching -
GATT Discovery 7 BluetoothDevice BluetoothAdapter BluetoothGatt Async Scan startLeScan(ScanCallback) stopLeScan()
ScanCallback.onLeScan() connectGatt(GattCallback) Async Scan startLeScan(ScanCallback) stopLeScan(ScanCallback) ScanCallback.onScanResult() BluetoothLeScanner -
GATT Discovery 8 BluetoothGattCallback BluetoothGatt BluetoothGattService BluetoothGattCharacteristic BluetoothGattDescriptor discoverServices() onServicesDiscovered()
getServices() getService(UUID) getCharacteristics() getCharacteristic(UUID) getDescriptors() getDescriptor(UUID) -
GATT Transactions 9 BluetoothGattCallback BluetoothGattCharacteristic BluetoothGattDescriptor BluetoothGatt readCharacteristic() writeCharacteristic() readDescriptor()
writeDescriptor() setCharacteristicNotification() onCharacteristicRead() onCharacteristicWrite() onCharacteristicChanged() onDescriptorRead() onDescriptorWrite() -
Advertising 10 BluetoothAdapter BluetoothLeAdvertiser Broadcast startAdvertising(AdvertiseData) stopAdvertising() Adver?seData Device Name
TX Power Level Manufacturer Data Service UUIDs Service Data Adver?seSeBngs TX Power Level Connectable Timeout Latency Mode -
Advertisement Data 11 AD Length AD Type AD Payload AD
Structure AD Structure AD Structure ... AD Structure public void onLeScan(BluetoothDevice, int rssi, byte[] scanRecord) Type IdenHfiers are Assigned Numbers by the Bluetooth SIG Device Name, Service UUIDs, Service Data, TX Power, etc. h]ps://www.bluetooth.org/en-us/specificaHon/assigned-numbers/generic-access-profile -
Stack Metrics • Constants defined in BlueDroid • Max concurrent
active notifications (BTA_GATTC_NOTIF_REG_MAX) – (4) Android 4.3 – (7) Android 4.4 – (15) Android 5.0+ • Max concurrent GATT connections (BTA_GATTC_CONN_MAX) – (4) Android 4.3 – (7) Android 4.4+ 12 -
Come Find Me! • Dave Smith • Twitter: @devunwired •
Google+: http://plus.google.com/+DaveSmithDev • Blog: http://wiresareobsolete.com • Beacon Hardware – http://www.kstechnologies.com/ • Samples – http://www.github.com/devunwired/accessory-samples • I/O Byte on Lollipop BLE Features – http://youtu.be/2fZThdNbHcQ 14