From ecec25d7194bb9835fef16da93f65a36ff1b1e29 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 28 Apr 2018 23:47:52 +0200 Subject: [PATCH] Specify transport LE on Android API >= 23 --- .../openscale/core/bluetooth/BluetoothCommunication.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java index f9c74466..c49a713f 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java @@ -27,6 +27,7 @@ import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Handler; import android.support.v4.content.ContextCompat; @@ -398,7 +399,13 @@ public abstract class BluetoothCommunication { btMachineState = BT_MACHINE_STATE.BT_CLEANUP_STATE; BluetoothDevice device = btAdapter.getRemoteDevice(hwAddress); - bluetoothGatt = device.connectGatt(context, false, gattCallback); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + bluetoothGatt = device.connectGatt( + context, false, gattCallback, BluetoothDevice.TRANSPORT_LE); + } + else { + bluetoothGatt = device.connectGatt(context, false, gattCallback); + } } /**