gpt4 book ai didi

Android 蓝牙 .connect() 异常 Nexus 7 OBDII 适配器

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:27:42 27 4
gpt4 key购买 nike

我正在使用标准 API 程序连接到设备。特别是 OBDII 蓝牙适配器。

我有两个不同型号的 OBDII 蓝牙适配器。运行完全相同的代码,第一个将毫无问题地与我测试过的每部手机/平板电脑配对和连接。第二个将配对并连接正常,除了我运行 android 4.2 的 Nexus 7

它抛出一个 IOexception: read failed, socket might closed or timeout, read ret: -1

我以为这只是设备本身或较新版本的问题......但后来另一个软件“torque”能够连接到我的 Nexus 7 的任一适配器。

所以我显然做错了/不同的事情,这只是后来操作系统中的问题???

如果您能帮助解决这个问题,我们将不胜感激。

    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;
}

最佳答案

我知道这是一个老问题。但是因为我无法在网上找到任何解决方案。搜索此内容的人可能对我找到的解决方法感兴趣:IOException: read failed, socket might closed - Bluetooth on Android 4.3

关于Android 蓝牙 .connect() 异常 Nexus 7 OBDII 适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15892665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com