Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t...
Transcript of Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t...
![Page 1: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/1.jpg)
© 201
3 Tie
to Co
rpora
tion
Bluetooth Low Energy on Android
Getting it done
Szymon Janc
Łukasz Rymanowski
Android Builders Summit 2013
![Page 2: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/2.jpg)
© 2013 Tieto Corporation
Agenda
Introduction
Quick Bluetooth Low Energy recap
Status of Android BLE support
Heart Rate profile for Android ICS and JB
Bluetooth Low Energy in Android 4.2
![Page 3: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/3.jpg)
© 2013 Tieto Corporation
About us
Łukasz and Szymon are Tieto employees
Tieto provides IT and SW engineering services
Both working in Local Connectivity area
Doing side projects exploring new technologies
![Page 4: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/4.jpg)
© 2013 Tieto Corporation
Bluetooth Low Energy (aka Smart)
Lower power
Lower latency
Lower throughput
Lower range
Sports and fitness
Medical & Other
Connected Watches
![Page 5: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/5.jpg)
© 2013 Tieto Corporation
Status of Android BLE support No API and support in Google AOSP
Current support is a real mess
Vendor specific solutions available
Broadcom API http://code.google.com/p/broadcom-ble/ http://android-btle.github.com/framework/ GATT based Use Broadcom BT stack
• Require BT framework extension from Broadcom
![Page 6: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/6.jpg)
© 2013 Tieto Corporation
Status of Android BLE support(part II)
Vendor specific solutions available (cont)
Code Aurora Forum API (Qualcomm) https://www.codeaurora.org/contribute/projects/qaep/ Use BlueZ stack – own highly modified branch Framework extensions GATT based API Source code available On 4.2 BT framework part 'reverted' to 4.1 and Bluedroid disabled
Motorola API http://www.motorola.com/sites/motodev/library/bluetooth_apis.html GATT and Profile based API Probably based on Code Aurora code
![Page 7: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/7.jpg)
© 201
3 Tie
to Co
rpora
tion
Hear Rate profile for Android ICS and JB 4.1
Android Builders Summit 2013
Our approach
![Page 8: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/8.jpg)
© 2013 Tieto Corporation
HRP for ICS and JB 4.1
● Bought Polar Heart Rate device
● Bought BT 4.0 USB dongle
● Start playing with it
● Solved teething problems in the stack
● Idea to add support to Android AOSP
![Page 9: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/9.jpg)
© 2013 Tieto Corporation
HRP for ICS and JB 4.1(part II)
● Keep code close to upstream
● Use compat-drivers for kernel BT subsystem upgrade
● Updated BlueZ daemon● 4.101+ (up to API breakage for 5.0 release)● plugin to handle Android specific tasks and API● Expose GATT connect/disconnect on DBus (for generic GATT API)● Heart Rate profile implemented in daemon
● Minimal changes to existing AOSP code
● Isolate framework and applications changes if possible
![Page 10: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/10.jpg)
© 2013 Tieto Corporation
HRP for ICS and JB 4.1(part III)
Architecture overview
![Page 11: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/11.jpg)
© 2013 Tieto Corporation
Demo
![Page 12: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/12.jpg)
© 201
3 Tie
to Co
rpora
tion
Android Jelly Bean 4.2
Android Builders Summit 2013
Challenge accepted
![Page 13: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/13.jpg)
© 2013 Tieto Corporation
Bluetooth on Android 4.2
● Major changes to BT subsystem architecture
● Bluedroid - completely new Bluetooth stack
● Based on contribution from Broadcom
● No DBus and system Bluetooth daemon
● Introduction of BT HAL API
● No HCI interface for userspace
● Linux kernel BT subsystem is not used
![Page 14: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/14.jpg)
© 2013 Tieto Corporation
New architecture and Low Energy
● Still no Low Energy framework API
● Bluedroid – Low Energy support not present
● Enabling related flags results in build error
● Some functions and files implementations are missing
● Looks like deliberately stripped off Low Energy support
● No Low Energy related API in BT HAL
![Page 15: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/15.jpg)
© 2013 Tieto Corporation
Try with BlueZ 5 instead● Has full support for Low Energy including number of profiles
● Community driven so can influence its development
● BT HAL – should minimize change impact on framework
● Could reuse code from 4.1 solution
● Some risks related to classic Bluetooth functionality
● BlueZ targets into not requiring config files in /etc
![Page 16: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/16.jpg)
© 2013 Tieto Corporation
BlueZ 5 as BT HAL● Enable HCI interface for adapter
● Use compat-drivers for updated
kernel Bluetooth subsystem
● Enable DBus daemon
● Enable BlueZ 5 daemon
● Add BT HAL implementation
● Prepare Tieto BLE Handler
● Reuse profile components
![Page 17: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/17.jpg)
© 2013 Tieto Corporation
Tieto BT HAL details
● libbluez - implements BT HAL API
● btal library to wrap DBus calls into
simple C API (used by libbluez)
● Provide available profiles by
extending get_profile_interface
call in BT HAL
![Page 18: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/18.jpg)
© 2013 Tieto Corporation
Risks and open points
● Classic Bluetooth support - feature parity with Bluedroid
● Support for A2DP – needs to wrap Media API
● HS/HFP – moved from BlueZ to oFono
● Google Bluetooth roadmap is unknown e.g. BT HAL changes
![Page 19: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/19.jpg)
© 2013 Tieto Corporation
Integration – K.I.S.S.
● Synchronize repository
● In device/FooCompany/BarProduct
● Define BOARD_HAVE_BLUETOOTH_BLUEZ in
BoardConfig.mk
● Declare services in init.BarProduct.rc
● DBus daemon, bluetoothd and hciattach
● Integrate compat-drivers if custom kernel is used
![Page 20: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/20.jpg)
© 201
3 Tie
to Co
rpora
tion
Questions?
More about Tieto and Bluetooth Low Energy
Android Builders Summit 2013
BlueZ BLE Profiles (contributions)
Cycling Speed and Cadence Profile
Hear Rate Profile
Blood PressureProfile (coming)
Medical thermometerProfile
Tieto BLE Component and Demos
• For Android 4.0-4.2 Heart Rate, Cadence and Multiple sensors• BlueZ and Android BLE profiles• Blood Pressure demo with customized peripheral
![Page 21: Bluetooth Low Energy on Android - events.static.linuxfound.org · 2 0 1 3 T i e t o C o r p o r a t i o n Bluetooth Low Energy on Android Getting it done Szymon Janc szymon.janc@tieto.com](https://reader036.fdocuments.us/reader036/viewer/2022070721/5ee15f89ad6a402d666c475f/html5/thumbnails/21.jpg)
© 201
3 Tie
to Co
rpora
tion
Thank You
Bluetooth Low Energy on AndroidGetting it done
Szymon Janc
Łukasz Rymanowski
Android Builders Summit 2013