android bluetooth stack

Post on 22-Jan-2018

1.602 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Nanik Tolaramnanikjava@yahoo.comnaniktolaram.com

ANDROID ANDROID BLUETOOTH BLUETOOTH

STACKSTACK

topic 2topic 3topic 4

Thank You Thank You !!

• 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

The StackThe Stack

BluetootBluetooth h • 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 vs Classic vs BLE BLE

Classic BLEStreaming 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

Bluetooth Low Bluetooth Low Energy Energy • Master Slave RoleMaster Slave Role

• Low Latency Connection - 3msLow Latency Connection - 3ms

Generic Access ProfileGeneric Access Profile• PRE ConnectionPRE Connection

• Determines connection, advertising and how Determines connection, advertising and how devices interactsdevices interacts

• Define roles – Define roles – PeripheralsPeripherals and and CentralCentral

• DefineDefine payload for Advertising Data and Scan payload for Advertising Data and Scan ResponseResponse

• Advertising ProcessAdvertising Process

Generic Attribute Generic Attribute ProfileProfile• POST Connection POST 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

Bluetooth ProfilesBluetooth Profiles

Source https://www.facebook.com/raytaccorporation/photos/a.557851494377619.1073741829.169782503184522/576294762533292/?type=3

Bluetooth Bluetooth StackStack

App1

Android Bluetooth Framework

Bluetooth Stack(Bluedroid / BlueZ)

Linux Kernel + FirmwareLinux Kernel + Firmware

Bluetooth Hardware

App2 App3 App4

Bluetooth System Bluetooth System FilesFiles• bluetooth.default.so bluetooth.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)

Switching Switching OnOn

libhardware.solibhardware.so

bluetooth.default.sobluetooth.default.so

Linux KernelLinux Kernel

libbluetooth_jni.solibbluetooth_jni.so

Bluetooth.apkBluetooth.apk

Bluez vs Bluez 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

Classic Classic Programming Programming • 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 connection Managed state connection

BLE BLE Programming Programming • Android 4.3+ (API 18) Android 4.3+ (API 18)

• Setting Up Bluetooth AdapterSetting Up Bluetooth Adapter

• Scanning for BLE devices Scanning for BLE devices

• Connecting to GATT Connecting to GATT

• Reading AttributesReading Attributes

• Receive NotificationReceive Notification

DemDemoo

Thank Thank YouYou

top related