android-4.3-jelly-bean
startLeScan with 128 bit UUIDs doesn’t work on native Android BLE implementation
@Navin’s code is good, but it includes an overflow bug from the original 16-bit Android code. (If either byte is larger than 127 then it becomes a negative integer.) Here’s an implementation which fixes that bug and adds 128-bit support: private List<UUID> parseUuids(byte[] advertisedData) { List<UUID> uuids = new ArrayList<UUID>(); ByteBuffer buffer = ByteBuffer.wrap(advertisedData).order(ByteOrder.LITTLE_ENDIAN); while … Read more
Android Bluetooth Low Energy Pairing
When you get the GATT_INSUFFICIENT_AUTHENTICATION error, the system starts the bonding process for you. In the example below I’m trying to enable notifications and indications on glucose monitor. First I’m enabling the notifications on Glucose Measurement characteristic which can cause the error to appear. @Override public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if … Read more
Communicating between iOS and Android with Bluetooth LE
I’ve already gone through this for at least one week having this same issue. I’ve already asked a question here and I’ve already answered on my own. The main problem is an Android BUG issue. It’s sending a non permitted command on a fixed L2CAP channnel. But when Android is communicating with normal peripheral BLE … Read more
Android BLE API: GATT Notification not received
It seems like you forgot to write the Descriptor which tells your BLE device to go in this mode. See the code lines that deal with descriptor at http://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification Without setting this descriptor, you never receive updates to a characteristic. Calling setCharacteristicNotification is not enough. This is a common mistake. code snipped protected static final … Read more
How to connect Android device to an iOS device over BLE (Bluetooth Low Energy)
Adding a summary for reference: What could it be? There are some limitations on Android or iOS that don’t permit to connect from an Android to an iOS or viceversa? When connecting to a GATT server that is advertised as dualmode (BLE and BR/EDR) device by calling connectGatt(…), the TRANSPORT_AUTO flag that is internally added … Read more
Chrome’s remote debugging (USB debugging) not working for Samsung Galaxy S3 running android 4.3
My devices stopped working as Chrome de-activated the now depracated ADB plugin as it’s built in dev-tools now. I downloaded the SDK and followed the instructions at Chrome Developers. How ever I found the instructions served by Alphonso out not to be sufficient and I did it this way on Windows 8: Download Android SDK … Read more
IOException: read failed, socket might closed – Bluetooth on Android 4.3
I have finally found a workaround. The magic is hidden under the hood of the BluetoothDevice class (see https://github.com/android/platform_frameworks_base/blob/android-4.3_r2/core/java/android/bluetooth/BluetoothDevice.java#L1037). Now, when I receive that exception, I instantiate a fallback BluetoothSocket, similar to the source code below. As you can see, invoking the hidden method createRfcommSocket via reflections. I have no clue why this method is … Read more
Android 4.3 Bluetooth Low Energy unstable
Important implementation hints (Perhaps some of those hints aren’t necessary anymore due to Android OS updates.) Some devices like Nexus 4 with Android 4.3 take 45+ seconds to connect using an existing gatt instance. Work around: Always close gatt instances on disconnect and create a fresh instance of gatt on each connect. Don’t forget to … Read more