I'm using standard API procedures for connecting to a device. Specifically OBDII bluetooth adapters.
I have two OBDII bluetooth adapters, of different models. Running the exact same code, the first will pair and connect without issue with every phone/tablet I've tested. The second will pair and connect fine except with my Nexus 7 running android 4.2
It throws an IOexception:
read failed, socket might closed or timeout, read ret: -1
Thought this was just something wrong with the device itself or the newer release... But then another piece of software "torque" is able to connect to either adapter from my Nexus 7.
So I'm clearly doing something wrong or different that is only an issue in the later OS?
Any help figuring this out would be greatly appreciated.
public void run() {
Log.i(TAG, "BEGIN mConnectThread");
setName("ConnectThread");
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect(); <=**This is where the exception is thrown
} catch (IOException e) {
Etype = "Connection to: " + mmDevice.getName() + " at: "
+ mmDevice.getAddress() + " failed: " + e.getMessage();
connectionFailed();
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() socket during connection failure", e2);
}
// Start the service over to restart listening mode
BluetoothChatService.this.start();
return;
}