Bluetooth exception Bluetooth.connect () Exclusive Nexus 7 OBDII adapter

I use standard API procedures to connect to the device. In particular, Bluetooth adapters OBDII.

I have two bluetooth OBDII adapters, different models. By running the same code, the first ones will be steamed and connected without problems to each tested phone / tablet. The second will connect and connect perfectly, except for my Nexus 7, which works with Android 4.2

It throws an IOexception: read failed, socket might closed or timeout, read ret: -1

I thought that it was something wrong with the device itself or with a later release ... But then another piece of “torque” software can connect to any adapter from my Nexus 7.

So, I am clearly doing something wrong / different, this is only a problem in a later OS.

Any help on this would be 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;
        }
+5
source share
1 answer

I know this is an old question. But since I could not find any solution on the Internet. People looking for this may be interested in the workaround I found: IOException: reading failed, socket may be closed - Bluetooth on Android 4.3

0
source

All Articles