Advertisement
Advertisement

More Related Content

Advertisement

Android Bluetooth Stack

  1. Nanik Tolaram nanikjava@yahoo.com naniktolaram.com ANDROIDANDROID BLUETOOTHBLUETOOTH STACKSTACK
  2.  topic 2  topic 3  topic 4 Thank YouThank You !!
  3. • 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
  4. The StackThe Stack
  5. 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
  6. 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
  7. Bluetooth LowBluetooth Low EnergyEnergy• Master Slave RoleMaster Slave Role • Low Latency Connection - 3msLow Latency Connection - 3ms
  8. 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
  9. 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
  10. Bluetooth ProfilesBluetooth Profiles Source https://www.facebook.com/raytaccorporation/photos/a.557851494377619.1073741829.169782503184522/576294762533292/?type=3
  11. BluetoothBluetooth StackStack App1 Android Bluetooth Framework Bluetooth Stack (Bluedroid / BlueZ) Linux Kernel + FirmwareLinux Kernel + Firmware Bluetooth Hardware App2 App3 App4
  12. Bluetooth SystemBluetooth System FilesFiles• bluetooth.default.sobluetooth.default.so (external/bluetooth/bluedroid)(external/bluetooth/bluedroid) • libbluetooth_jni.so (packages/app/Bluetooth/jni)libbluetooth_jni.so (packages/app/Bluetooth/jni) • libbt-utils.so (external/bluetooth/bluedroid)libbt-utils.so (external/bluetooth/bluedroid) • libbt-vendor.so (hardware/<vendor>)libbt-vendor.so (hardware/<vendor>) • libbt-hci.so (external/bluedroid/main)libbt-hci.so (external/bluedroid/main)
  13. SwitchingSwitching OnOn libhardware.solibhardware.so bluetooth.default.sobluetooth.default.so Linux KernelLinux Kernel libbluetooth_jni.solibbluetooth_jni.so Bluetooth.apkBluetooth.apk
  14. 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
  15. 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
  16. 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
  17. DemDem oo
  18. ThankThank YouYou
Advertisement