Erel, can you please add those function to the BLE2 library.
1. I had a problem with connection to my BLE device and found out that adding the BlueToothTransport parameter (= 2) will help.
Connect to the BLE device using BlueToothTransport parameter.
2. Connect to the paired device with a known Mac Address - without a need for scanning! This makes connection quicker.
Although, I don't need this, because I have compiled BLE2 library with those functions, but I think that some people may find them useful.
1. I had a problem with connection to my BLE device and found out that adding the BlueToothTransport parameter (= 2) will help.
Connect to the BLE device using BlueToothTransport parameter.
Java:
/*
* BT_TRANSPORT_AUTO 0
* BT_TRANSPORT_BR_EDR 1
* BT_TRANSPORT_LE 2
* */
public void Connect3(String DeviceId, boolean AutoConnect, int BtTransport) {
charsToReadQueue.clear();
BluetoothDevice bd = this.devices.get(DeviceId);
int Transport = BtTransport;
if(Transport > 2){
Transport = 0;
}
if (bd == null)
throw new RuntimeException("MacAddress not found. Make sure to call Scan before trying to connect.");
bd.connectGatt(BA.applicationContext, AutoConnect, new GattCallback(), Transport);
}
2. Connect to the paired device with a known Mac Address - without a need for scanning! This makes connection quicker.
Java:
public void ConnectToAddress(String DeviceId, boolean AutoConnect, int BtTransport){
BluetoothDevice device = blueAdapter.getRemoteDevice(DeviceId);
BluetoothDevice bd = this.devices.get(DeviceId);
int Transport = BtTransport;
if(Transport > 2){
Transport = 0;
}
int bs = device.getBondState();
if(bs == BluetoothDevice.BOND_BONDED){
device.connectGatt(BA.applicationContext, AutoConnect, new GattCallback(), Transport);
}
else{
String sMac = device.getAddress();
Toast.makeText(BA.applicationContext, "Device " + sMac + " not Bonded", Toast.LENGTH_SHORT).show();
}
}
Although, I don't need this, because I have compiled BLE2 library with those functions, but I think that some people may find them useful.
Last edited: