BLE performance issue on recent Android versions - android

I am developing an Android app based on the sample project BluetoothLeGatt provided by Google, that exchanges BLE data with another device.
Tests run on Android 4.3 (API 18 - Samsung Galaxy S3) worked fine, but when I tried it on Android 6.0 (API 23 - HTC One M8), I noticed significant performance issues: the BLE seems to slow down the application, which display haltingly the data received through notifications.
As I suppose that the HTC is more efficient, is it due to the BLE implementation on newer Android APIs? Or the sample project that is out of date?
Thanks in advance for your help

I finally found the solution. Actually the issue didn't came from the Android "Central role" side. It came from the "Peripheral role" side played by my TI SensorTag, which updates automatically the connection parameters after 6 seconds, to go under some kind of low power mode (with a longer connection interval).
6 months later... that's never too late!

Related

Android 6 / Samsung network issue

I've developed an Android app for remote controlling some special hardware devices. The communication is done via udp and wifi. The app already runs on ~60k devices without any problems but since the rollout of Android 6 I'm getting more and more reports from users who get some strange errors:
Usually the app searches for the hardware with a broadcast package. The app then requests all data from the hardware to stay in sync (~4000 packages in both directions). This sync process is heavily tested with all wifi conditions possible and does work as intended (also on Android 6).
User with a Samsung device and Android 6 are now having the issue, that the sync is unable to complete (no reply from the hardware within 20 seconds). The odd thing is that the broadcast search does work just fine, as well as the beginning of the sync. Usually the timeout happens when 5-15% of the sync was completed.
As I have no idea what could cause this issue I wanted to ask if there is any known problems with Samsung / Android 6 and udp communication via wifi?
Also were there any other changes on the network stack in Android 6 that could cause this issue? On my test devices (HTC mostly) everything runs fine so I'm currently out of ideas.
Edit:
I narrowed the issue down to the following devices:
Samsung Galaxy 6
Samsung Galaxy 6 Edge
Samsung Galaxy Note 5
Edit 2:
I got a Samsung Galaxy 6 device for testing purposes and of course it does work for me. I also tried all sorts of network setup, power saving, anti virus and general settings combination but it's just working all the time.
Edit 3:
After getting some Galaxy S5 and S6 test devices I was not able to reproduce the problem. Comparing the ROM version I found out that these devices all have a newer rom than the devices which got the issues.
Turns out that Samsung simply broke something in their wifi stack which causes the wifi to stop working properly after some udp packages. So only fix for this issue is to wait and hope they fix it in all countries soon.

Android: Limit of simultaneous BLE connections

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

Android Lollipop 5.0 Bluetooth Low Energy central role's bad performance

Since the recent release of Android 5.0 Lollipop I am experiencing very bad performance of the Bluetooth Low Energy API in my Nexus 4 device. With the previous OS version (Android 4.4.4 Kit-Kat) it worked like a charm, and the very same app run on 5.0 has the following behavior:
Frequently it does not detect any advertising packet from the peripheral.
The ADVERTISING_INTERVAL of the peripheral is 20ms, so the app should detect at least one advertising in 60ms in the worst case. I have tried with BluetoothLeScanner (with SCAN_MODE_LOW_LATENCY settings) not to use the deprecated mBluetoothAdapter.startLeScan(mLeScanCallback) with no success.
When it does, when I try to connect to the GATT server it rarely does.
I have checked with a BLE sniffer that the CONNECTION_REQUEST packet
is not even sent to the peripheral.
It seems I'm not the only one with this kind of errors and some other users have posted similar questions. Does anybody know what has happened?
--
Update 1: (2014/12/17)
I have also tested the same app with a Nexus 5 running Lollipop and it rarely connects to the GATT server. Every time I send a connection request, it never does because the peripheral does not receive the packet. Before upgrading this Nexus 5 to Lollipop, it worked perfectly on Kit-Kat 4.4.4 though.
Update 2: (2014/12/17)
Android 5.0.1 does not solve the problem at all.
Update 3: (2015/04/23)
Android 5.1 does not solve the problem either. Today I've had the opportunity to test Android 5.0.1 on a SAMSUNG Galaxy S4 and it works perfectly. I have also tested on the Nexus 5 with a fresh Android 5.1 install, and it works fine too. The problem still remains in the Nexus 4. They made something strange on the the firmware of Android 5.0 and subsequent releases that broke the perfect compatibility Android 4.4.4 had with the Bluetooth API.
reedited to a clearer answer
Last week i had some problems with bt after upgrading to 5.0 . Maybe
you can stop the bt process from apps in settings and it possibly
will reset everything like so:
Settings -> Apps -> Scroll over to All -> Select Bluetooth Share -> Clear Cache.
Shutting those services in instantiate them have been known to solve
this issue in some cases. you can also follow this link if it is
more clear:
http://www.gottabemobile.com/2014/12/01/nexus-lollipop-problems-fixes/
In my case i am nor expert in Bluetooth but I did solve this problems
after many trials. And I discovered that unplaging the bt dongle from
pc help also.
It is not generally recommended to upgrade so soon without checking
competency to bluetooth. As far as I have understood bt is known to
have issues at each upgrade
Good luck with your endeavor. If this answer is not enough I hope you find help from someone else.
I Think I may have found the answer
I had the same problem, it took 2-5 minutes to connect to my device AFTER I upgraded to Lollipop
This took 5 seconds before the upgrade.
The Fix:
Old code :
mBluetoothGatt = mBluetoothDevice.connectGatt(this, true, mGattCallbackSync);
new code :
mBluetoothGatt = mBluetoothDevice.connectGatt(this, false, mGattCallbackSync);
I just changed the autoConnect argument to false. It takes 5 seconds to connect now.
I hope this works for you.

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.

Android 2.3 vs 2.2.1 Bluetooth

Can anyone tell me if there have been any changes to the bluetooth functionality in the Android update?
I have an app which uses transmission and reception concurrently with a total of 5 connected devices and this works perfectly on a Motorola Droid2 with 2.2.1 but not on the ATRIX running 2.3
There may of course be a hardware element involved but I wanted to establish this first.
thanks in advance.
John
I had the problem that the bluetooth connection worked only on the second try - the first one almost always fails internally (IOException). And you don't have much time in between trials. This was on my 2.3.3 Sony phone. Logcat showed some messages that might imply an internal problem in bluez or with the bluez/java integration.
This problem did not manifest on a 2.2.x Samsung phone. Note that my program only uses one connection at a time.
Android website says "updated BlueZ stack", but that's all.
Did you check the logs, what are the errors you're getting?
Also, I guess you can try running different emulators with different versions of Android and see how that behaves.

Categories

Resources