Presentation to look at Android's Bluetooth Stack for Sydney Android Meetup http://www.meetup.com/Android-Australia-User-Group-Sydney/events/227303382/
• Android Platform Engineer@ BlocksGlobal.comAndroid Platform Engineer@ BlocksGlobal.com
• ScreenerOS –ScreenerOS – www.screener.digitalwww.screener.digital &&
LumenHealth – www.lumenhealth.coLumenHealth – www.lumenhealth.co
• Android writer for magazine.odroid.comAndroid writer for magazine.odroid.com
• AOSP Contributor - now and then :)AOSP Contributor - now and then :)
About MeAbout Me
BluetootBluetoot
hh• Bluetooth Classic vs Bluetooth Low EnergyBluetooth Classic vs Bluetooth Low Energy
• Single Mode vs Dual ModeSingle Mode vs Dual Mode
• Different way of programmingDifferent way of programming
• Android devices are Dual Mode devicesAndroid devices are Dual Mode devices
Classic vsClassic vs
BLEBLE
Classic BLE
Streaming Data (headset,
speaker, etc)
Low data transfer
Up to 7 slaves Large no of slaves
Standard profiles (SPP, DUN,
PAN)
Profiles based on Generic Attribute Profile
(GATT)
Weak connection setup Strong connection setup
Wider coverage Shorter coverage
Power hungry Low power
Generic Access ProfileGeneric Access Profile
• PRE ConnectionPRE Connection
• Determines connection, advertising and howDetermines connection, advertising and how
devices interactsdevices interacts
• Define roles –Define roles – PeripheralsPeripherals andand CentralCentral
• DefineDefine payload for Advertising Data and Scanpayload for Advertising Data and Scan
ResponseResponse
• Advertising ProcessAdvertising Process
Generic AttributeGeneric Attribute
ProfileProfile• POST ConnectionPOST Connection
• Define way for data transfer between devicesDefine way for data transfer between devices
Profiles → collection of
Services
Services → distinguished by
UUID
Characteristics → encapsulates
a single data point
Bluez vsBluez vs
BluedroidBluedroid• Community drivenCommunity driven
• Initiate by community vs vendorInitiate by community vs vendor
• Bluez very strong in Linux worldBluez very strong in Linux world
• Bluedroid strong in Android worldBluedroid strong in Android world
ClassicClassic
ProgrammingProgramming• Using BluetoothSocketUsing BluetoothSocket
• Pairing process using PINPairing process using PIN
• Blocking call when connectingBlocking call when connecting
• Thread management (important !)Thread management (important !)
• Managed state connectionManaged state connection
BLEBLE
ProgrammingProgramming• Android 4.3+ (API 18)Android 4.3+ (API 18)
• Setting Up Bluetooth AdapterSetting Up Bluetooth Adapter
• Scanning for BLE devicesScanning for BLE devices
• Connecting to GATTConnecting to GATT
• Reading AttributesReading Attributes
• Receive NotificationReceive Notification