读取失败插座有可能关闭或超时

读取失败插座有可能关闭或超时

本文介绍了Android的蓝牙连接错误(读取失败插座有可能关闭或超时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Andr​​oid设备的应用程序连接到远程设备(配对)。远程设备是一个模块HC-05。
我的code是:

I want to connect from my app in android device to a remote device (paired). The remote device is a module HC-05.
my code is:

UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //Standard SerialPortService ID

try {
    mSocket = MyDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
    Toast.makeText(this, "S", Toast.LENGTH_SHORT).show();
}

ba.cancelDiscovery();

try {
    mSocket.connect();
} catch (IOException e){
    Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();

    Log.e("YOUR_APP_LOG_TAG1", "I got an error", e);
}

try {
    mOutputStream = mSocket.getOutputStream();
    mInputStream = mSocket.getInputStream();
} catch (IOException e) {
    Toast.makeText(this, "io", Toast.LENGTH_SHORT).show();
}

不过,我在排队mSocket.connect(错误)。

But I get an error in line mSocket.connect().

错误:

读取失败插座可能会关闭或暂停读RET

请大家帮帮忙。

推荐答案

这可以通过很多的东西造成的 - 在我的情况下,我发现有三种:

This can be caused by lots of things - in my case I have found three:

  1. 电力问题 - HC-05是不稳定的,甚至可以通过它没有一个noticable LED闪烁模式显示出这一点。更换电池解决了这个问题。

  1. Power issues - HC-05 wasn't stable, even through it didn't show this with a noticable LED blinking pattern. Battery replacement fixed this.

另一种设备是搭配HC-05,有时甚至偷的连接。通过AT指令进行一些设置可能可以解决的,但我只是简单地配对的一切,但一台设备。

Another device was paired with HC-05 and sometimes "stole" the connection. Possibly fixable by some setup with AT commands, but I just simply unpaired everything but one device.

该设备被关闭/超出范围。

The device is off/out of range.

这篇关于Android的蓝牙连接错误(读取失败插座有可能关闭或超时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 02:43