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

How to get the battery level after connect to the BLE device?

I have solved this problem. public class BluetoothLeService extends Service { private static final UUID Battery_Service_UUID = UUID.fromString(“0000180F-0000-1000-8000-00805f9b34fb”); private static final UUID Battery_Level_UUID = UUID.fromString(“00002a19-0000-1000-8000-00805f9b34fb”); public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { if(status == BluetoothGatt.GATT_SUCCESS) { broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic); } } private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { final Intent intent = … Read more

run-as Package ‘a.b.c’ is unknown – Galaxy S4 Jellybean or Android 4.3

Found success by adding this to the activity: private void startGdbServer() { try { new ProcessBuilder() .command(getFilesDir().getParent() + “/lib/gdbserver”, “tcp:5039”, “–attach” ,”” + android.os.Process.myPid()) .redirectErrorStream(true) .start(); } catch (IOException e) { Log.e(TAG, “IOException failed to start gdbserver”); } } Then I wrapped startGdbServer in an Android service and updating the ndk-gdb script to start the … Read more

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