Android: Limit of simultaneous BLE connections - android

we are developing an Android app which can connect to multiple heart rate sensors simultaneoulsy via Bluetooth Low Energy.
We have an implementation which is working quite well, so the code is not the problem.
What drives us crazy is the limitation of parallel BLE-connections which seems to be different from device to device.
We have a few test devices here: Motorola MotoE and MotoG, a Samsung Galaxy Tab A and an HTC Nexus 9. All of them are running Android 5 or 6, original vendor versions. None of them is able to connect to more than 7 BLE HR sensors simultaneously.
Then I have tested with my private Samsung Galaxy S4, which is rooted and has Cyanogen CM12 installed. With this device I can easily connect to 12 HR sensors simultaneously which is the number we want to achieve with our app.
I have tested this both with our own app implementation and with the Nordic Semiconductor nRF Master Control Panel which I think is a pretty good generic BLE app: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=de
When I try to connect the app to a 7th BLE sensor on any of our devices, the ADB output prints the following error message:
E/BluetoothLeBasicConn: Connection state changing error: 133
I did some pretty intensive googling about that whole problem, but most of the results I've found were quite old. Some people said, that the limitation came from the Bluetooth Chipset itself, others said it was a software limitation through Android.
Could you help me to find out, where the limitation is coming from?
If it is the chipset, then I would like to know, which devices we should use for supporting as many parallel connections as possible. Sadly it is very hard to find out which Bluetooth chipset is built in the different devices. Hardly any of the hardware specs I found tell anything about this.
If the limitation comes from software side, can we change it somehow without rooting phones or install modded OS?
Thank you very much!

In case that you are still interested in it. The limit comes from
BTA_GATTC_CONN_MAX (hardcoded in android)
Which is set to:
4 on Android 4.3 and
7 on Android 4.4
There is by the way also a limit on the amount of characteristics for which you can activate notifications. (BTA_GATTC_NOTIF_REG_MAX)
which is:
4 on Android 4.3,
7 on Android 4.4 and
15 on Android 5.0

Related

HTC BLE problems and kontakt.io beacons api

I wrote and app using kontakt.io api and examples for beacons.
This app correctly work on Sony Xperia SP, but when I use different models of HTC smartphones (like HTC Desire 820) this app work really slowly (active time for scanning is 3 seconds, for passive scanning - 2 seconds).
If I use Bluetooth scanning on the HTC (via settings of smartphone) - I had same problems. Very slow work (slow scanning).
Can somebody explain, why is so? Maybe this problem is only on HTC?
Disclaimer: I work for Kontakt.io, although not as an Android developer
Unfortunately the biggest strength of Android, its openness and variety, is IMHO also a source of the weakness that you see right now. Different manufacturers use different Bluetooth chipsets, antennas, etc. in their devices. All of the possible combinations usually work in typical Bluetooth use cases, like connecting to Bluetooth speakers, keyboards, etc., but some of them fail when something more is required (e.g. scanning beacons).
In my experience latest Samsung flagships are pretty reliable, but e.g. OnePlus phones have a lot of problems with beacons. Similarly, Nexus 5 is one of the best Android phones when it comes to working with beacons, but Nexus 5X really struggles with detecting them. You've mentioned Sony Xperia SP, that it works OK, but we had Xperia Z (don't remember the exact model, sorry) and it was horrible. Apparently your HTC falls into the Bad BLE category :-(
This is a prioprietary software, so you should ask Kontakt SDK developer.
From my side I would suggest a following thing: check Android version system both devices operate on. BLE Android API was introduced in Android 4.3 and got huge refactor in Android 5.0. So this maybe the case of slow scanning.
Also take into consideration, that BLE devices do not broadcast their presence all the time, as one of their purposes is very low battery usage.

How many devices we can pair via Bluetooth of BLE to Android?

How many devices can be connected to at one time via Bluetooth using the BLE firmware on Android?
A search of the Android Bluetooth Firmware source shows the following:
Max concurrent active synchronous connections (BTA_GATTC_CONN_MAX):
4 on Android 4.3
7 on Android 4.4+
Max concurrent active notifications (BTA_GATTC_NOTIF_REG_MAX):
4 on Android 4.3
7 on Android 4.4
15 on Android 5.0+
As a comparison my experience with iOS is that 8 devices can be connected at at time.
I tried connecting more than 7 devices the other day on Android 7.1 and Bluetooth stopped responding. Starting and stopping didn't help; the only thing that fixed it was restarting the device.
After working with several apps that connect to 4+ devices I can say from experience that these numbers are theoretical. Depending on each individual device and its hardware you'll have an easier or harder time connecting to and maintaining a connection to the maximum number of BLE devices.
Follow Bluetooth at Wikipedia,
A master Bluetooth device can communicate with a maximum of seven devices in a piconet (an ad-hoc computer network using Bluetooth technology), though not all devices reach this maximum.
You need know Master/Slave in Bluetooth first.
I think the good answer depend on your aim.
You're right when you know "can communicate with how many devices" depend on Hardware (Bluetooth Chip).
Bluetooth chip on Apple iPhone 4, 5 or Samsung Galaxy S3, S4 ... totally different with Basic Bluetooth Chip.
In my case :
I'm working with Firmware side related to BLE.
His peripheral device has used Basic Bluetooth Chip since it did not has enough memory to store many capacities as many features, likes Bluetooth chip on Apple iPhone 4, 5 or Samsung Galaxy S3, S4 ....
Therefore, his peripheral device only paired with one device in one time.
Thanks,
Both of the answers here are wanting so I thought I should add one:
There are connection limitations built in to the different BLE hardware. I think the lowest I've encountered is 3 connections at once and the highest was about 12-13 connections. These were limitations due to the design of the hardware and had nothing to do with the OS being used, though. Usually the limitation is due to the fact that the hardware has to keep track of certain data and there's a limited amount of memory in the hardware.
So, I don't know specifically for Android, but it doesn't make much sense for a limitation to be imposed at the OS level. Likely when you try to make a connection, and you've reached the limit due to the hardware, you should receive some sort of error/exception preventing the new connection. I think there's actually a "connection limit" error in Bluetooth, but some hardware gives other exceptions like "out of resources". Again, I'm not sure how that gets reflected on the Android level.
I come into BLE development without any knowledge in Classic Bluetooth development and I really don't know what "pair" means in BLE. Isn't that something only exists in Classic Bluetooth?
If you are talking about connection, when Android 4.3 first came out I made a few test on the SDK on Nexus 7 2013. The maximum number of devices it can connect is 4. I didn't test if this number changes in 4.4, but I can confirm it will not be anything less than 4.
For every system, be it any firmware or OS like Android or iOS, there is a configured maximum concurrent connection limit. But in reality the connection parameters of each connection play a very important role in determining weather or not the system will be able to achieve that many concurrent connections.
For example, if the configure connection limit is 4 then the system can not have more than 4 concurrent connections. But if all of the connected devices are demanding a higher connection interval(say a 50mS connection interval) then the system may not be able to support all of them. This results in either some of the connections dropping out or not being able to connect entirely. But if the connection parameters are a bit relaxed(say a 1sec connection interval) then all the connections can be serviced properly.

Bluetooth Low Energy Sensor Simulator

First of all, I spent more than 10 hours of searching for a solution on Google...
I'm working on an app for athletes, doing sports like running or cycling. It should be based on Bluetooth LowEnergy. I have a real heartbeat sensor device to work with and there is the problem.
The Problem is that the sensor doesn't always work if I want to test the scan or something. My phone isn't able to find the sensor all the time, it works just one out of 30 attempts. So what I want to ask is, is there a way to simulate a BLE sensor device like a heartbeat-sensor (over the PC for example)?
I have devices running 4.3 and higher (Samsung, LG and a Sony smartphone), so that shouldn't be the problem. Furthermore I already had a success in connecting to a BLE-Heartbeat sensor, but for testing it's really hard to work with a real sensor device (because of the problem that I can't find it all the time).
Hope my problem is understandable and somebody can help me!
As #bobh says, an old iOS device running a custom app would work as a test BLE peripheral. And I bought an iPod Touch for just that purpose.
Unfortunately Android has only introduced native BLE support as of 4.3 and won't yet work in "peripheral" mode.
There are cheaper alternatives too. There are many BLE dev kits out there:
https://developer.bluetooth.org/DevelopmentResources/DevelopmentPlatforms/Pages/Development-Platforms.aspx
If you don't want to mess around with wires and breadboards then you could try BlueGiga's programmable BLE USB dongle. It's about 26 bucks and they have example code for the Heart Rate Profile so your life would be very easy:
http://www.bluegiga.com/en-US/products/bluetooth-4.0-modules/bled112-bluetooth-smart-dongle/
If you have an old iPhone 4S or iPad 3 and are an iPhone dev (or jailbroken device), you can prog it to be a test device https://github.com/AttackPattern/BlueSim
And tweek the sensor characteristics.
Works on a Mac with old Xcode 5 and BLE dongle but requires some work.
github

Bluetooth Low Energy Discovery on Android

It seem Bluetooth Low Energy (aka Bluetooth Smart) has no official support on Android, even version 4.2. Anyone know if the standard Android API can discovery BLE devices? (I don't need pairing just discovery would be good)
It is correct that Android took a switch from Bluez -> Broadcom Bluetooth. This switch was causing lots of problems for Android users. Missing BT classic profiles and Wifi v.s. BT coexistence (one probably reset the other since they are in the same chipset in most phones). iPhone and MAC computers suffer a lot from the same problem (BT v.s. Wifi).
The Broadcom Open Source Low Energy API was not included in 4.2.
HTC One X+ got slightly modified (?) Broadcom BLE API on top of Bluez in 4.1.x and it works reasonably good though I have to retry connection sometimes. The package name is htc not broadcom but sometimes Eclipse error messages tells that it is missing some broadcom references.
Also Samsung got a "secret" API for BT BLE with their own package name which can discover devices but seems to be not really robust (which may be why it is "secret")
Google have officially said that "BLE is the next big thing we will release". So maybe in Android 5.0? but hopefully before so Galaxy S2 (which have such a big marketshare and uses the same chipset as iPhone 4s) can get BLE support. (Just speculations and hopes from my side). If Android 5.0 get's BLE API's then Samsung Galaxy S3 should get it as Samsung has listed this as getting Android 5.0.
Only time or Google will tell... It's way overtime getting this old Nokia Research Center technology out in other than Meego and iOS devices.
EDIT 2: Seems like my lucky day is today ;) : new link
EDIT: Seems like today is your lucky day: Open Source API
I guess this answer is not adequate, but it is: on some devices yes, on others no.
A company I worked for did some testing with it and they could pair in on a Galaxy S3 while my HTC One S didn't even discover it.
So if a manufacturer has implemented this feature it will work, but most times it won't.
Some discussion about this: Texas Instruments
Sounds like a standard api will be coming to Android api 18 http://www.androidpolice.com/2013/05/15/bluetooth-low-energy-and-avrcp-1-3-coming-to-android-with-api-level-18/
Devices with the relevant hardware will work with Android 4.3.x support. I just put a Galaxy S2 GT-I9100 to 4.3.1 Slimbean and can now pair it with a Bluetooth 4.0 LE/Smart heart rate monitor. This, in spite of the stock hardware only ever supporting BT 3.0+, according to Samsung.

Bluetooth connection with Android

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.

Categories

Resources