mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 08:13:43 +02:00
Specify transport LE on Android API >= 23
This commit is contained in:
@@ -27,6 +27,7 @@ import android.bluetooth.BluetoothGattService;
|
|||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
@@ -398,8 +399,14 @@ public abstract class BluetoothCommunication {
|
|||||||
btMachineState = BT_MACHINE_STATE.BT_CLEANUP_STATE;
|
btMachineState = BT_MACHINE_STATE.BT_CLEANUP_STATE;
|
||||||
|
|
||||||
BluetoothDevice device = btAdapter.getRemoteDevice(hwAddress);
|
BluetoothDevice device = btAdapter.getRemoteDevice(hwAddress);
|
||||||
|
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);
|
bluetoothGatt = device.connectGatt(context, false, gattCallback);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from a Bluetooth device
|
* Disconnect from a Bluetooth device
|
||||||
|
Reference in New Issue
Block a user