Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ble_interface: enable connection priority setting #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down