I'm trying to find way to work with Bluetooth 4.0 (AKA Bluetooth Smart) devices using modern Android smartphones, namely - HTC One V.
As I understood, there is some issues using GATT profile even in Android 4.0 with Bluetooth 4.0 hardware because of API limitations.
I saw Motorola released it's own API for BT LE, but not sure it will work for other vendors.
My goal is to get universal support for all smartphones with appropriate hardware.
Any suggestion for solution are highly appreciated.
Alexey
PS: Yes, I saw Android API for HDP, but it seems to be used only with 'classic' Bluetooth devices (not low energy ones, as BT LE does).
Unfortunately there are no Android native GATT APIs simply because Android currently does not support Bluetooth Low Energy at all. This may change in upcoming Android releases, but today manufacturers instead integrate 3rd party Bluetooth stacks with Low Energy support from vendors like Qualcomm, Broadcom or CSR. Those come with their own set of APIs, obviously limiting compatibility to the set of phones using that particular vendor's stack.
The good news is that on other platforms like iOS or Windows 8 there are native GATT BLE APIs, and those are well supported. For Android, we will have to wait until Google decides to integrate the Linux/BlueZ work that has been done on BLE with Android.
After some research I can only say this:
Motorola has sided with Broadcom to develop a proprietary API. It would seem it is extremely limited since it states there's support for existing profiles only. Check it out here.
Samsung fails to provide any information regarding its BLE API, which I can verify exists and is called samsung.bluetoothle. I actually decompiled some apps from Google Play that use the SGSIII's BLE capabilities and found a couple of methods that do not exist in Android's native BT API, and they're names clearly state they're BLE related. I've tried using them through java reflection and am currently working out the possibility of developing a library. But tests I've run so far have had shakey results at best. There is also a thread on Samsung's developer forum, I would suggest making some pressure here if you're interested.
Google has made almost no remarks in this aspect. There's a thread regarding this issues in the Galaxy Nexus, which you should star, with a lot of people complaining. The closest thing to an answer from Google can be found here.
[UPDATE]
Samsung has also modified a couple of Android's classes, more especifically:
BluetoothAdapter
BluetoothDevice
[UPDATE]
Since I've put this issue aside for a while due to lack of support from both Google and Samsung I'll post what I've learned so far:
BluetoothAdapter new methods:
public boolean android.bluetooth.BluetoothAdapter.leTestEnd()
public boolean android.bluetooth.BluetoothAdapter.setAvStreaming(boolean)
public boolean android.bluetooth.BluetoothAdapter.setScanLE(boolean)
public void android.bluetooth.BluetoothAdapter.setScoPathChange(int)
public boolean android.bluetooth.BluetoothAdapter.startLeDiscovery()
To use them do the following:
BluetoothAdapter ba = new BluetoothAdapter();
Method starteLeDiscoveryMethod = null;
starteLeDiscoveryMethod = ba.class.getMethod("startLeDiscovery");
starteLeDiscoveryMethod.invoke(ba);
NOTE: This method in particular works somewhat like the regular startDiscovery() method but, at least for me, it discovers the BLE device 2 out of 5 times.
And remember, this is only for the SGSIII. I haven't gotten around to extracting the new methods in BluetoothDevice but when I do, I'll post them here.
SDK 18 has support for it now. Docs are here:
http://developer.android.com/guide/topics/connectivity/bluetooth-le.html
Testing on my Nexus 4 is crashing the bluetooth stack.
HTC has had BLE support since last year with HTC One X+, Droid DNA and of course the HTC One. Initially the HTC BLE API was upon request but it's now been freely downloadable at http://htcdev.com.
Yes the new standard Android BLE API from Google in Android API Level 18 is coming very soon (see preview from IO video) - but you can wrap third party APIs (HTC, Samsung, etc) in a compatible way to support the new standard API as all the APIs are quite similar in their support of the GATT profile (similar to IOS).
BluetoothGatt api available in andorid
https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html
As discovered, 4.3 has support for BLE, but it so broken, especially on Nexus devices.
At my opinion, it's not ready for production.
Related
I'm working on an app using bluetooth LE technology. I am trying to build a bi-directional communication between two devices, and first thought Bluetooth LE was the perfect choice at first.
But then the more I learn about it the more disappointed I became, because it looks like not enough devices support the peripheral feature, even though this has been introduced a long time ago.
I know the central role is possible in most cases, but for my app to work, I need to make sure there are enough devices out there that support (and will support) the peripheral role as well.
But I'm really not sure what the situation is because I couldn't find any reputable source which has a list of devices that support the peripheral feature. And due to the fragmented nature of the ecosystem I have no idea if this is something hardware vendors are planning on dropping or if the coverage will increase.
Can anyone share some insights?
Edit: I have already read another answer suggested as a duplicate (Chipsets/Devices supporting Android 5 BLE peripheral mode) as well as almost everything I could find on Stackoverflow about this topic. But I have yet to come across a definitive list of what devices support this feature, and what the future of this feature is. It's extremely frustrating not knowing whether I should even rely on this API or not because while they say it depends on the hardware vendor, NO hardware vendors include this information in their device spec, which is why I asked this question.
A good rule of thumb seems to be that devices which have Bluetooth chips with version 4.1 or above have proper support for the peripheral role.
Otherwise all Bluetooth devices and their features are listed on https://www.bluetooth.org/tpg/listings.cfm. Note that you might have to search for the model number and not brand name, like LG-H790 instead of Nexus 5X. Then press >> DISPLAY ICS DETAILS >>.
But maybe you can use Bluetooth classic? Android - communicating between two devices
Quick question. I can't seem to find this in the Android docs, so I don't think it is possible, but is it possible to have an Android 4.3 device (in my case, a Nexus 4) behave as a Bluetooth peripheral? I know iOS supports both peripheral and central, but it seems like Android only supports central.
I'd like to connect an Android device to a Mac using Bluetooth LE, but since OS X doesn't support peripheral mode and it looks like Android doesn't either, I might have to go with Bluetooth 2 or another communication method.
Unfortunately there is no way for Android devices to act as a peripheral. He can creates GATT servers, services and charachteristics but there is no way to make the advertising.
Doc: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html
The phone supports the central role;
I'm waiting for this feature too, but it seems we have to wait for next Android releases.
Yeah, Android 4.3 does not support peripheral mode. I started a feature request on the Android Open Source Project website. If you also want to see this feature, add a comment or star the post. I think they will get around to it eventually, but it is good to let them know that this is a feature that developers are looking for.
https://code.google.com/p/android/issues/detail?can=2&q=59693&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&id=59693
issue: 59693
In API level 4, 4.1,4.2,4.3 its not possible.
Android lollipop API version 5.0.X sdk supports peripheral mode in BLE however this feature is chipset dependent (Phones).
android phones with Broadcom Bluetooth solution already supports it
If you have a Nexus 5 you can install Android L there and try it, I just did it few months ago, Android L has support to act as a peripheral.
In my App I need to connect a smartphone with an 4.0 low power Bluetooth-module. Then the module sends frequenly data to the phone.
Do you know some good tutorials for programming Bluetooth connection
with Android?
Can you give me some links where the basics of Bluetooth are
explained? (german if possible)
How can I test it? (I have to programm the Bluetooth device too
and it's not finished jet)
Google havn't understood that sometimes they have to actually create and DRIVE something themselves, not just piggybacking on open source stuff and marketing it as their own.
Unfortunately there are no standardised BT 4.0. Low Energy API's for Android yet. Maybe Google just decided to only go for NFC for Google Wallet or something and then let BLE die. (We really need BOTH!)
Broadcom tried to make an open source API but somehow (maybe Broadcom wanted money from them?) no phones included the ".so" file in their Android build so this API is useless.
TI and Motorola made another API for the RAZR series running on old Android 2.3.3 or something. This actually works but Motorola removed the documentation and source-code from their site.
HTC ONE X+ and newer HTC phones will support a new API "soon" with special HTC libraries according to HTC. (At least it seems they are doing something)
Samsung Galaxy S3 have some "secret" API's that some people can use for discovering devices, scanning services and characteristics (there is an app in google play "semilink Bluetooth Smart Scanner" which on the Galaxy S3 can do those things).
Google asked Broadcom to make a replacement for Bluez in Android 4.2. Unfortunately this release broke a lot of functionality and peripheral compatibility. Maybe because one or more of Wifi/GPS/Bluetooth Classic/Bluetooth Low Energy shares the same HW resources but the drivers doesn't handle that very well. Lot's of people got problems with the newest Android Bluetooth functionality.
So I would expect Broadcom to focus on fixing the mess and THEN with Google move on to add Bluetooth 4.0. Low Energy. Google have said "Low Energy is the next BIG thing we will integrate". At least 1 year too late.
Personally I had to buy an iPhone4S and iPad retina to get platforms which supports low energy. With those we could finish the BLE peripheral sw and get the protocols working. Now we are waiting for Google and Broadcom to clean up the mess. Hopefully with some backwards compatibility so all the old phones with BT4.0. capable chipsets will also open up to the wonderful world of coincell battery driven peripherals ;-) (got to dream).
In reality we must wait for HTC to release their APIs and for Google to choose/drive the standard API.
Windows Phone 8 was supposed to get BLE but it has been postponed for an update. (Lumia 920 is certified but without API's (AGAIN!!) we developers are helpless)
There are nice GATT API's for Windows 8 as well as for MAC "OS"x.
You really should invest in the TI BLE development kit which costs like $50-$100 for a dongle which can be used for BLE sniffing. It comes SOOO handy when you develop your BLE Peripheral SW.
I am involved in a Android Project that connects the sensor using Bluetooth 4.0. AFAIK android didn't support Bluetooth 4.0. I tried with my laptop bluetooth 4.0. I tried with Broadcom using this. Later i came to know my Laptop Bluetooth 4.0 is Atheros Bluetooth 4.0 and later i searched for Atheros Bluetooth 4.0 API using android mobiles and tablets. I saw Qualcomm having Bluetooth 4.0 tablet. I want to know, is Atheros giving API for Bluetooth 4.0 for Android SDK.
Finally, long way of search, i found that up to today(23/12/12), Atheros not giving Bluetooth API for developers. But they are providing other API's for Audio, Camera, Device Info and Sensor(mobile shake). So, can't try on laptop also. Dgel comment and link helped me a lot and made me, come to the conclusion.
Android Bluetooth (and other) API's are not specific to the hardware (or software stack).
They are generic and fairly high-level, and Yes they include Bluetooth 4.0.
The actually support for BT 4 depends on the device. Recent Nexus devices support BT4 (both in hardware and in software) as long as they have the Android 4.2 update.
If you root your device you can get to the 'raw' vendor API's, but I don't know what that looks like for BT4, or wheteher any of that is published. In most cases that is Broadcom based, not Atheros.
EDIT:
I just saw this:
http://code.google.com/p/broadcom-ble/
I'm not familiar with this, but I suspect that it was just a stop gap measure before BT4 was added to the official Android API in 4.1.
Can anyone point me towards a tried and tested development kit (board) for Bluetooth Low Energy?
I am especially interested in the proximity profile, and compatibility with smartphone (especially iPhones and Android devices - but also any other that would have BTLE).
Also, can you tell me which smartphones would support the proximity profile?
If you are looking for API support for BT LE features then there is very little at the moment. For example, Android at API16 does not support. It is all rather disappointing so far. In many instances the HW supports it but the middleware / upper layers do not. There is SOME support on iOS (with Iphone4s) and with certain Moto phones (need the SDK add on) but it is limited.
iOS is probably your best bet (who'd have thought that).
Personally I am looking to use the GAP and GATT interface on Android (ICS/JB), which is mandatory for a BT4.0 listed device (such as the BT ICs in high end smartphones) but GAP does not seem to be exposed.
Oh, and if you need a dev kit (for SW dev then this link might help > http://blog.bluetooth-smart.com/2011/10/05/bluetooth-low-energy-development-kits-2/)
The Bluegiga DKBLE112 Development Board (out of the box) can communicate with the iPhone 4S on IOS 6. The IOS code tutorials by http://olesitune.mine.nu/blelogg/?page_id=78 and http://olesitune.mine.nu/blelogg/?page_id=180 will discover the DKBLE112, the built-in thermometer service, and the associated characteristics. The code displays the BLE information on the iPhone and in the Xcode Console if the iPhone is tethered through USB. The DKBLE112 is expensive (nearly $400) but it does include many capabilities that I have not yet explored.
I note that tod list devices that have BT4.0 functionality. Of course that does not guarantee that APIs will be exposed in the SDK. If you stick with an already implemented profile then you may be ok but as I said, you certainly will not find that in the Android API16. SO, custom implementations.
One of the nice things with BT LE is that profiles are relatively "light" and hence, you can pretty easily make your own...but if the phone side API does not give access to the lower level (only talking GAP and GATT here) then not much use..
The guys who produce the tod seem to have done pretty well with a BLE device that functions as a proximity sensor.
They've managed to get their device working on the following phones:
iPhone 4s, Droid Razr and Razr Maxx, Samsung Galaxy S3, HTC One S, X, V, LG Optimus LTE2, Droid 4, Droid Incredible 4G LTE, HTC EVO 4g LTE, HTC Desire C, Sony Xperia GX, Sony Xperia SX, ASUS PadFone
So it is possible. My recommendation for a dev kit is the Bluegiga BLE112 with a CC Debugger from Texas Instruments. Your options for programming are either the $4,000 IAR compiler, the proprietary Bluegiga API "BGScript" (if you don't have access to IAR), or use an external microcontroller with the compiler of your choice.
I am using a TI ez430-rf256x development kit with "IAR Embedded Workbench for MSP430 v5.51.5". When TI 1st released the ez430, they were using a crappy stack that was buggy and just wasn't capable. They have now switched to a Bluetopia based stack and it is great! It comes with a LOT of samples, supports ALL profiles (including all the new low energy profiles), and is easy to use. I believe the Bluetopia stack also supports I have it talking to my Galaxy Nexus over classic bluetooth, but unfortunately, as of Android 4.2.2, there is still no support for Bluetooth low energy (which the ez430 does support.) It appears that Google may address this issue in Android 4.2.3. In my opinion, there is no reason to use something like Bluegiga, as you will pay more in licensing costs to them, than you will spend on a compiler like IAR. This is a link to an explanation of the new stack that TI is using: http://www.stonestreetone.com/bluetopiaLE.cfm
I realize this is an old question and in disclosure I am a developer on this project: Anaren Atmosphere.
Anaren has produced a Bluetooth Smart Multi-Sensor Development Board with the A27037 module based on the Broadcom BCM27037 that is compatible with the Wiced SDK. It also features an online development environment that is a GUI/IDE that allows you to both program the module and create associated iOS and android applications to communicate with it.
The development kit is available from various distributors and the development tool is free to use.