デバイスへの接続に標準の API 手順を使用しています。特に OBDII Bluetooth アダプター。
異なるモデルの 2 つの OBDII Bluetooth アダプターがあります。まったく同じコードを実行すると、最初のコードは、テストしたすべての電話/タブレットと問題なくペアリングおよび接続されます. 2つ目は、Android 4.2を実行しているNexus 7を除いて、ペアリングして正常に接続します
IOexception をスローします。read failed, socket might closed or timeout, read ret: -1
これは、デバイス自体または新しいリリースに問題があるだけだと思っていました...しかし、別のソフトウェア「トルク」は、Nexus 7のいずれかのアダプターに接続できます.
だから私は明らかに、後のOSの問題だけである間違った/異なることをしていますか???
これを理解するための助けをいただければ幸いです。
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;
}