CANblue II with Android



I’m working on a driver for Android that would allow communication with a CANblue II.

I’m able to pair easily enough, but when it comes to creating an RFCOMM socket, I get an exception when calling connect():

IOException: read failed, socket might closed

There’s some information out there regarding the createRfcommSocketToServiceRecord and accessing the underlying createRfcommSocket, but using both methods (as well as the Insecure variant) has resulted in the same exception.

There’s an article from 2013 that says:

There is also an Android sample implementation available.

But I haven’t been able to find anything like this.

Has anyone had any success with Android and Bluetooth on any Ixxat products? Is there an example floating around somewhere? Or is the VCI


Here is an Android programming example: (189.8 KB)
Screenshots_CANblue_ADK_Demo_11_01_2019.ZIP (636.5 KB)
4_01_0126_20000-CANblue-extended-A4-EN-V3_2.pdf (2.2 MB)

It is using an older Android version (v6), but may be able to help get you started. I don’t have experience personally with this, but if you have questions I can get information from the IXXAT developers.


Thanks - using this, I was able to determine that for the CANblue II, the createInsecureRfcommSocket hidden method must be used with a port value of 2, rather than 1 (the example code provided tries both).

Copied from the example code, for posterity:

      // Make a connection to the BluetoothSocket.
      // There are 2ways of connecting to the device.
      // First by using the default port (UUID).
      // Second by manually defining the port and try to connect to
      // one of the port.

      // The CANblue could connect using either secure
      // and insecure communication mode, but CANblue II could only
      // connect using insecure communication mode, so the insecure
      // communication mode is used.

      // First way, currently not used.
      //try {
      //    driverBluetoothSocket =
      //        driverBluetoothDevice.
      //        createInsecureRfcommSocketToServiceRecord(
      //        MY_UUID_INSECURE);
      //} catch (IOException e) {
      //    return com.ixxat.canblue.ReturnCode.FAIL_CREATING_BLUETOOTH_SOCKET;
      //try {
      //    // This is a blocking call and will only return on a
      //    // successful connection or an exception
      //    driverBluetoothSocket.connect();
      //} catch (IOException e) {
      //    // Close the socket
      //    try {
      //        driverBluetoothSocket.close();
      //    } catch (IOException e2) {
      //        return com.ixxat.canblue.ReturnCode.FAIL_CLOSING_BLUETOOTH_SOCKET;
      //    }
      //    return com.ixxat.canblue.ReturnCode.FAIL_OPENING_BLUETOOTH_SOCKET;

      // Second way, try to connect to the port 1-2.
      // Since the CANblue II has 2 ports, it should first be tried to connect to port 1.
      // If this fails, connect to port 2.
      // This must be done since the order of the ports has changed in the meantime and
      // the connection can only be established to the SPP port with the name "Config".
      // The device CANblue has only 1 port.
      byte portNumber;
      byte maxPortNumber;
      boolean openingBluetoothSocketFailed;

      if (intDeviceList.deviceType[listIndex] == DeviceType.CANBLUE)
        portNumber = 1;
        maxPortNumber = 1;
      else if (intDeviceList.deviceType[listIndex] == DeviceType.CANBLUE_II)
        portNumber = 1;
        maxPortNumber = 2;
        return ReturnCode.UNKNOWN_DEVICE;

        openingBluetoothSocketFailed = false;

          Method insecureMethod = driverBluetoothDevice.getClass().getMethod(
              "createInsecureRfcommSocket", new Class[]{int.class});

          driverBluetoothSocket = (BluetoothSocket) insecureMethod.invoke(
              driverBluetoothDevice, portNumber);
        catch (Exception e)
          return ReturnCode.FAIL_CREATING_BLUETOOTH_SOCKET;

        // Try to connect to the Bluetooth device.
          // This is a blocking call and will only return on a
          // successful connection or an exception if failed.
        catch (Exception e1)
          // Failed to connect to the device.
          // Try to close the socket.
          catch (Exception e2)
            return ReturnCode.FAIL_CLOSING_BLUETOOTH_SOCKET;

          openingBluetoothSocketFailed = true;
          if(portNumber < maxPortNumber)
            /* try again to set up the connection with the next port number */
            return ReturnCode.FAIL_OPENING_BLUETOOTH_SOCKET;
      }while(openingBluetoothSocketFailed == true);


I’m glad that helped @owen, please let us know how this turns out for you and if you have any additional questions.