diff --git a/xbee_android_library/src/main/java/com/digi/xbee/api/android/XBeeBLEDevice.java b/xbee_android_library/src/main/java/com/digi/xbee/api/android/XBeeBLEDevice.java index 8e86d90..679ad57 100644 --- a/xbee_android_library/src/main/java/com/digi/xbee/api/android/XBeeBLEDevice.java +++ b/xbee_android_library/src/main/java/com/digi/xbee/api/android/XBeeBLEDevice.java @@ -17,8 +17,11 @@ import android.bluetooth.BluetoothDevice; import android.content.Context; +import android.os.Build; +import android.support.annotation.RequiresApi; import com.digi.xbee.api.AbstractXBeeDevice; +import com.digi.xbee.api.android.connection.bluetooth.AndroidBluetoothInterface; import com.digi.xbee.api.exceptions.TimeoutException; import com.digi.xbee.api.exceptions.XBeeException; import com.digi.xbee.api.listeners.IPacketReceiveListener; @@ -85,6 +88,12 @@ public XBeeBLEDevice(Context context, String deviceAddress, String password) { this.bluetoothPassword = password; } + public void requestConnectionPriority(int connectionPriority) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + ((AndroidBluetoothInterface)super.connectionInterface).requestConnectionPriority(connectionPriority); + } + } + @Override public boolean isRemote() { return false; diff --git a/xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/bluetooth/AndroidBluetoothInterface.java b/xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/bluetooth/AndroidBluetoothInterface.java index 97c6fca..7b302ad 100644 --- a/xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/bluetooth/AndroidBluetoothInterface.java +++ b/xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/bluetooth/AndroidBluetoothInterface.java @@ -25,6 +25,8 @@ import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; import android.content.Context; +import android.os.Build; +import android.support.annotation.RequiresApi; import com.digi.xbee.api.connection.bluetooth.AbstractBluetoothInterface; import com.digi.xbee.api.exceptions.InvalidInterfaceException; @@ -133,6 +135,11 @@ public AndroidBluetoothInterface(Context context, String deviceAddress) { bleGattCallback = new BLEGattCallback(); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public void requestConnectionPriority(int connectionPriority) { + bluetoothGatt.requestConnectionPriority(connectionPriority); + } + @Override public void open() throws InvalidInterfaceException { // Do nothing if the device is already open.