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