蓝牙安卓问题
我正在 android 和 adobe air 上运行一个多线程应用程序,在本机 android 2 蓝牙套接字中设置了几个服务器线程,以便air应用程序与本机 android 的蓝牙套接字进行通信。它基本上是套接字编程,并且全部可以在我用来编程的一台设备上运行。
我用来开发这个应用程序的设备很慢,因此我给自己买了另一台平板电脑来测试(android vega),它在传输我的蓝牙数据方面非常快,因为它有 2.1edr 版本。
问题在于 Advent Vega 平板电脑,蓝牙流会无缘无故地间歇性地断开连接,在 adb 日志窗口中,当断开连接发生时,我只是突然尝试连接到设备,我没有提到任何地方的崩溃日志中,这同时发生在两个蓝牙连接的线程上,因此我怀疑它一定与蓝牙无线电有关。另一台平板电脑设备可以正常运行该应用程序,但速度较慢(不会断开连接)。我什至在 vega 上安装了一个自定义的 3.0 rom,以查看是否是操作系统问题,但断开连接问题在 3.0 上也仍然存在。
由于 adb 日志中没有提及这一点,我基本上只是盯着屏幕,不知道为什么它现在断开连接了 2 天!发生此断开连接后让应用程序再次运行的唯一方法是重新启动设备上的蓝牙,但下次运行时最终会再次发生此断开连接。当应用程序在重新启动后首次运行时,它似乎提高了它保持活动状态并传输数据的时间。
我已经检查了每个线程的 run() 和stopping() 的所有代码,它似乎正常退出,我只关闭蓝牙套接字,从研究看来不需要关闭蓝牙输入和输出,但我也尝试过这种关闭方式。
任何人都可以提供关于为什么蓝牙读/写循环会突然停止并断开连接的建议吗?似乎影响了 adb 日志,并且它只是说尝试连接...
或者关于如何在发生这种情况时更好地调试的任何建议?
或者甚至其他人在这种情况下会做什么。
希望有人可以提供帮助,我为 Android 平板电脑所有者社区提供了一个很棒的手机远程应用程序,它取决于我已经坚持了 2 天的最后一个问题。
I am running a multi thread application on android and adobe air, in native android 2 bluetooth sockets are set up and a couple of server threads for the air app to communicate with the bluetooth sockets of native android. It's basically socket programming and it all works on one device I used to programme it.
The device i used to develop this app was slow, i therefore got myself another tablet to test (android vega) and it is very fast at communicating my bluetooth data as it has 2.1edr version.
The problem is with the Advent Vega tablet the bluetooth streams just disconnect for no apparent reason intermittently and in the adb log window i just get trying to connect to device all of a sudden when the disconnect occurs, i have no mention of the crash anywhere in the log, this happens to both bluetooth connected threads at the same time so it must be something to do with the bluetooth radio im suspecting. The other tablet device runs the app fine but slower (no disconnects). I have even installed a custom 3.0 rom on the vega to see if it was a os problem but the disconnect problem persisted on 3.0 as well.
Due to the fact there is no mention of this in the adb log i am just basically staring at a screen with no idea of why it disconnects for 2 days now!! The only way to get the app to run again after this disconnection occurs is to restart the bluetooth on the device but this disconnect occurs again eventually when next run. It seems to improve the amount of time it stays alive tansferring data when the app is first run afater a re boot.
I have gone through all code of the run() and stopping() of each thread and it seems to exit gracefully, i close the bluetooth sockets only, it seems from research no need to close the bluetooth input and output but i have also tried that approach to closing.
Can anyone offer suggestions as to why both bluetooth read/write loops would just stop all of a sudden and disconnect? Seemingly effecting the adb log as well as it just says trying to connect...
Or any suggestions as to how to better debug when this occurs?
Or even what somebody else would do in this situation.
Hope someone can help, i have a great phone remote app for the android tablet owner community and it hinges on this final issue which i have been stuck on for 2 days.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了断开连接的问题,并通过发送 ping 请求和 ping ack 实现了 keepalive。
这对我来说效果很好......
I had problems with disconnects, and implemented a keepalive by sending a ping request and a ping ack.
This worked fine for me...