I am trying to connect to a bluetooth device, which i can pair to when setting the target device in pair mode, but trying to reconnect with the following method causes errors. The Code that causes it:
StreamConnection streamConnection = null;
try {
streamConnection = (StreamConnection)Connector.open("btspp://A0E6F8FECB26:1;authenticate=false;encrypt=false;master=false");
callback.onSocketCreated(streamConnection);
callback.onConnectionSucceed();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The Exception That occurs
java.io.IOException: Failed to connect. [13] Permission denied
at com.intel.bluetooth.BluetoothStackBlueZ.connectionRfOpenClientConnectionImpl(Native Method)
at com.intel.bluetooth.BluetoothStackBlueZ.connectionRfOpenClientConnection(BluetoothStackBlueZ.java:574)
at com.intel.bluetooth.BluetoothRFCommClientConnection.<init>(BluetoothRFCommClientConnection.java:37)
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:379)
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:162)
at javax.microedition.io.Connector.open(Connector.java:83)
at insight.utils.ConnectionEstablisher.run(ConnectionEstablisher.java:170)
I have to use Java and this is the only Library I found (That somewhat works) for this purpose:
BlueCove version 2.1.1-SNAPSHOT on bluez
I am on Arch Linux with the newest bluez Version and I have already tried This Fix to no avail.
Any help is appreciated
So essentially, the issue was the entire Bluetooth Stack / how it propagates "pairing requests" to the Bluetooth Stack.
As a sidenote I was using BlueZ (5.56) on Arch Linux and the bluecove library for Java.
I was looking into alternative Bluetooth Stacks and thought about trying the same code on Windows 10, which doesnt use the BlueZ Stack.
Windows then popped up a window where it asked if i wanted to pair to this device.
This was the main difference between Windows and Linux. Windows / its bluetooth stack or whatever is responsible for it, actually registered the device as "paired".
This then allowed me to re-connect to the device without any "Permission Denied" issues.
Hope this helps anyone that has to deal with this library or has similar issues.