Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  1. 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.

  2. 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.

like image 940
GoRoS Avatar asked Nov 27 '14 11:11

GoRoS


People also ask

Is Android 5.1 Lollipop still supported?

Android Lollipop operating system (5.0, 5.1) no longer supported.

How do I turn off Bluetooth low energy Android?

Users can disable system-level Bluetooth background scanning by going to Settings > Security & Location > Location > Scanning and disabling the toggle for Bluetooth scanning.

What is Bluetooth low energy in Android?

Android provides built-in platform support for Bluetooth Low Energy (BLE) in the central role and provides APIs that apps can use to discover devices, query for services, and transmit information. Common use cases include the following: Transferring small amounts of data between nearby devices.

What phones support Bluetooth low energy?

Mobile operating systems including iOS, Android, Windows Phone and BlackBerry, as well as macOS, Linux, Windows 8, Windows 10 and Windows 11, natively support Bluetooth Low Energy.


2 Answers

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.

like image 132
sivi Avatar answered Sep 21 '22 02:09

sivi


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.

like image 21
kmn Avatar answered Sep 22 '22 02:09

kmn