2011-09-12 71 views
3

我有一个应用程序通过蓝牙与beagle板上的服务器通话。我在C++中使用bluez和平板电脑上的Android应用程序创建了服务器代码。蓝牙重新连接崩溃平板电脑蜂窝3.2

我看到的问题是服务器应用程序未启动时,我希望平板电脑继续尝试连接。尽管在随机数次的尝试后,平板电脑将会崩溃并且实际上会重新启动。服务器应用程序可能没有运行,但操作系统正在运行并且蓝牙技术上处于开启状态。它只是监听端口没有监听,因为服务器应用程序没有运行。

2台设备已连接,并且在一切正常运行时都不会出现问题。用例是当服务器没有运行并且平板电脑试图通过通信环路连接时。它显然不会连接,因为服务器应用程序没有运行,这很好。我只是不明白为什么在重试一段时间后它锁定了平板电脑。

平板电脑冻结前,重试次数从40次到300次到1000次不等。这不是内存泄漏,正如我在logcat中可以看到的那样,在它崩溃之前有10%的空闲空间。我正在关闭所有套接字和流,并在每次重试连接尝试时打开新鲜事物,因此我没有看到任何问题。

就在我连接之前,我检查以确保发现没有运行,因为我正在连接到绑定设备。

所以我认为我在连接上的错误是因为服务器没有运行,因此没有侦听端口打开。这是有效的,因为我正在测试一个错误情况。我只是需要帮助,为什么失败的连接会多次强制重新启动平板电脑。

D UI_BT: stateMachineCurrent: Connecting

E BluetoothEventLoop.cpp: onDiscoverServicesResult: D-Bus error: org.bluez.Error.InProgress (Discover in progress)

D BluetoothService: Cleaning up failed UUID channel lookup: 00:02:76:24:C2:8F 00001101-0000-1000-8000-00805f9b34fb

D UI_BT: FAILED Connection (95) - java.io.IOException: Service discovery failed

有人有一个想法可能是什么错?谢谢。

编辑:

这是一些更多的信息。我决定看看它是否与蓝牙打开有关,beagle电路板上没有应用程序运行,蓝牙关闭。我整晚试了一次,重试了650万次,平板电脑没有崩溃,这很棒。

现在我打开蓝牙并启动我的应用程序,我希望一切都开始进行通信。我觉得这是一个通信链接的标准用例。一旦一切都开始像以前一样谈论平板电脑崩溃。

下面是一些logcat的输出...

09-13 09:23:28.600 7581 7590 D UI_BT : stateMachineCurrent: Connecting

09-13 09:23:28.600 5419 5670 D BluetoothService: updateDeviceServiceChannelCache(00:02:76:24:C2:8F)

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.680 5875 5878 D dalvikvm: GC_CONCURRENT freed 467K, 14% free 6435K/7431K, paused 2ms+24ms

所以我不知道为什么我收到这么多的UUID的行动意图。虽然我认为我的问题的根本原因可能与updateDeviceServiceChannelCache()调用有关?我不确定答案是什么,但是经过长时间的重新启动后,内部电话会不知何故地搞砸了?我知道这个方法是由于我的代码调用connect例程而执行的。所以我不直接调用它。

希望这些增加的信息将有助于有人指向我的决议。

谢谢!

回答

0

看起来问题是因为某些原因,使用createRfcommSocketToServiceRecord()时,这个方法不喜欢在没有连接时反复故障转移。

相反,我使用了反射和createRfcommSocket()来解决我的问题。

+0

你可以请解释一下这个createRfcommSocket()?我在XOOM平板电脑上遇到了同样的问题,但找不到device.createRfcommSocket()方法,只是device.createRfcommSockettoServiceRecord()。谢谢 –

+0

发现它在这里:http://stackoverflow.com/questions/2660968/how-to-prevent-android-bluetooth-rfcomm-connection-from-dying-immediately-after –

相关问题