17
votes

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.

2
I had the similar problem. Can you check with turning off wifi if it is enabled. Im not sure but It may help .Ajay
I can confirm that Nexus 5 on 5.0.1 can connect to SOME peripherals without problem, but also having great trouble while connecting the others. Asked about the difference of the peripherals, seems that Lollipop breaks support of connection to peripherals with certain range of signal frequency. I am not a hardware guy, so cannot explain/understand that well enough, though.reTs
@reTs do you have any reference of that 'breaks support of connection to peripherals with certain range of signal frequency' ? I'd appreciate it. Anyway, I'm still staggered to see how the change form 4.4.4 to 5.0 has these fails without keeping backwards compatibility.GoRoS
@GoRoS Double checked with my boss, it is not about signal frequency. The hardware maker told us there is a bug in the BLE implementation for 5.0, but they didn't give us the detail. Everything works on 5.0 after they change the firmware.reTs
My code is working on Lollipop the only thing is 1 or 2 packets are lost every 3 to 4 times(bcz at the time of sending to the connected BLE it actually disconnects!!!!) I make a pulse to transmit and send some data to my BLE hardware(I made it myself the Hardware + fimware). there's no problem in connections to a BLE whos advertising in peripheral role (my app grasps advertising ), so far havent made any changes to the app code to handle BLE on Lollipop, But overall its bad performance on 5.0 Lollipop.Naaz

2 Answers

1
votes

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.

1
votes

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.