Friday, October 18, 2013

Android and Bluetooth Low Energy

Talk by Dario Laverde, Senior Developer Evangelist for HTC

Bluetooth Low Energy began in 2001 was introduced with Nokia's Wibree and merged with the main standard in 2010 with Bluetooth 4.0.

The Bluetooth 4.0 core specifications include the classic Bluetooth technology, Bluetooth Low Energy and Bluetooth SMART. Hardware-wise Classic Bluetooth is limited to a 100 meter range with a transfer rate of one to three Mbit/s and uses under 30 mA while BLE utilizes a max range of 50 meters, has a 1 Mbit/s transfer rate and uses under 15 mA of power.

We have seen Bluetooth Low Energy used in health, fitness and proximity but there are many more possibilities. These uses have their own specifications known as BLE Profiles. These are for particular applications and manufacturers are expected to implement specs to ensure compatibility but are not required by the core specification itself.

Some profiles include:
HRP: Heart Rate Profile for pulse monitoring
HTP: Health Thermometer Profile for medical temperature measurement
GLP: Glucose Profile for blood glucose monitors
CSCP: Cycling Speed and Cadence Profile
RSP: Running Speed Profile
FMP: Find Me Profile
PXP: Proximity Profile that allows the device to detect if another device is near

BLE manufacturers are encouraged by Bluetooth SIG to create new profiles and extend others with proprietary characteristics to expand the original ones. This does create difficulty, however, with app developers having to contact the 3rd party manufacturers for specifications. BLE Profiles sit on top of the Generic Attribute Profile on the Host and shares the same radio with the classic Bluetooth but has many layers removed to make it more efficient.

BLE Protocols
General Attribute Profile (GATT)
Phone, the master/central role has the GATT Client, and the BLE Smart device, which is Slave/Peripheral and contains the Service and the Characteristic with the value and descriptors. There are some roles left out including the Broadcast Role. Android BLE only supports the central role but IOS supports both.

BLE GATT Clients and Servers
Servers expose the attributes while the clients use them. The Client Actions include discovering, reading, writing, confirming and indicating while the Server Actions include responding to the client actions, sending notifications and indicating.
To find more information, go to the Bluetooth SIG portal.

BLE Developer Device Kits
BLE chipset OEMs provide device kits which support different profiles. Texas Instruments' Sensorial has a bevy of sensors including acceleration, rotation, pressure, humidity, magnetic field and temperature.

Prior to Android 4.3, several OEMs already have devices on the market that support BLE and each provide their own BLE API including HTC, Samsung, Motorola and others. The BLE API was formally announced at Google IO 2013 and includes API Level 18. In most, if not all, cases, you will build on top of the GATT profile so your app must include the implementation of your required BLE profiles.

Demos
Scanning works slightly different than Classic Bluetooth in that it has its own callbacks.
It is more efficient in that by searching for Low Energy devices allows much faster scans compared to a scan for both classic and low energy Bluetooth devices. Sadly a known issue in Android is that, for the time being, it will only allow four sensor notifications.

Q & A
Resources/References
https://d.android.com/guide/topics/connectivity/bluetooth-le.html
http://processors.wiki.ti.com/index.php/Bluetooth_SensorTag
http://www.htcdev.com/devcenter/opensense-sdk/bluetooth-smart
Bluetooth SIG, Google IO 2013, TI.com/ble,
https://github.com/RadiusNetworks/android-ibeacon-service
contact info: dario.nycjava@gmail.com

No comments: