Wifi 和蓝牙发现问题
我有一个应用程序需要将蓝牙发现过程保持在循环中,以始终发现新的蓝牙设备(当 BroadcastReceiver 获取 BluetoothAdapter.ACTION_DISCOVERY_FINISHED 时,我只需再次调用 startDiscovery() )。我最近向应用程序添加了一些套接字通信,基本上打开了到服务器的套接字,发送数据,然后关闭套接字。
当我使用 3G 时,一切工作正常,嗅探器显示没有 TCP 重传,套接字干净地打开和关闭。然而,使用 Wifi 会出现大量 TCP 重传,有时甚至无法连接套接字(出现 java.net.SocketException 超时)。
我使用的是运行 Android 2.2.1 的 Samsung Galaxy S。有什么我忽略的吗?
I have an application that needs to keep the bluetooth discovery process in a loop to always discover new bluetooth devices (when the BroadcastReceiver gets a BluetoothAdapter.ACTION_DISCOVERY_FINISHED, I just call the startDiscovery() again). I've recently added some socket communication to the app, that basically opens a Socket to a server, sends data and then closes the socket.
When I'm using 3G, everything works fine and a sniffer shows no TCP Retransmissions, the socket is cleanly opened and closed. Using Wifi, however, shows lots of TCP Retransmissions and sometimes even failures to connect the socket (with java.net.SocketException timeout).
I'm using a Samsung Galaxy S with Android 2.2.1. Is there something I'm overlooking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试配置 WiFi 并将其移至不同的频道吗?如果您也在 2.4 GHz 频段使用 WiFi,则预计会出现干扰,特别是在初始发现/连接期间,连接后应该会变得更好,因为蓝牙应该跳频以避免干扰(除非 WiFi 堵塞了整个频谱)
Can you try to configure and move WiFi to a different channel ? If you are using WiFi also in the 2.4 GHz band interference is expected specially during initial discovery / connection, after connection it should become better as Bluetooth should frequency hop to avoid interference (unless WiFi is clogging the complete spectrum)