在睡眠模式下没有收到UDP广播数据包数据包、睡眠、模式下、UDP

由网友(偽妳鈊∮誶)分享简介:我的Andr​​oid应用程序定期发送,并在无线LAN接收UDP广播消息。当显示屏上,一切工作正常,所有消息的发送和正确接收。当显示器进入睡眠状态的应用程序却停止接收UDP广播消息(但仍然将它们发送)。 获取的WiFiLock(以及组播锁)似乎并没有什么差别,我的无线休眠策略设置为WIFI_SLEEP_POLICY_N...

我的Andr​​oid应用程序定期发送,并在无线LAN接收UDP广播消息。当显示屏上,一切工作正常,所有消息的发送和正确接收。当显示器进入睡眠状态的应用程序却停止接收UDP广播消息(但仍然将它们发送)。

获取的WiFiLock(以及组播锁)似乎并没有什么差别,我的无线休眠策略设置为WIFI_SLEEP_POLICY_NEVER。

这是在Android 2.3.3和2.3.5(三星GALAXY SII手机)的问题,而不是在一个旧的HTC Hero运行氰MOD了Android 2.3.7的问题。

任何人都有这个问题,并找到了解决方法?

解决方案

这个谷歌组线程处理的问题:

的https://groups.google.com/forum/?fromgroups=#!topic/android-platform/OpbSdp9FTmA

它做一定的芯片组和深睡眠。基本上,司机发现时,该设备进入深度睡眠,并关闭UDP广播接收。根据我的经验,UDP发送仍然有效和UDP发送/监听设备上也将听到的数据包,但它是一个幽灵,该设备实际上是个聋子。

下面的建议是我使用的:

     获取一个PARTIAL_WAKE_LOCK和陷阱当屏幕熄灭。然后禁用和重新启用的无线网络连接。这样做是因为过滤器   只有轮流当屏幕熄灭,所以开始的WiFi与   屏幕关闭将继续它的工作,直到屏幕再次熄灭。本   就是我们做之前,我们找到了解决方案(1)。    利用UDP压缩提升数据包吞吐能力

My Android application periodically sends and receives UDP broadcast messages on the WiFi LAN. When the display is on, everything works fine and all messages are sent and received correctly. When the display goes to sleep the application however stops receiving UDP broadcast messages (but still sends them).

Acquiring the WiFiLock (as well as a Multicast Lock) does not seem to make any difference and my wifi sleep policy is set to WIFI_SLEEP_POLICY_NEVER.

This is an issue on Android 2.3.3 and 2.3.5 (Samsung galaxy SII phones) but not an issue on an old HTC Hero running cyanogen mod with android 2.3.7.

Has anyone else had this problem and found a solution?

解决方案

This Google Groups thread deals with the problem:

https://groups.google.com/forum/?fromgroups=#!topic/android-platform/OpbSdp9FTmA

It has to do with certain chipsets and deep sleep. Basically, drivers detect when the device goes into a deep sleep and shut down UDP Broadcast Reception. In my experience, UDP send still works and a UDP send/listen on the device will also hear packets, but it's a ghost, the device is actually deaf.

The following recommendation is what I use:

Acquire a PARTIAL_WAKE_LOCK, and trap when the screen goes off. Then disable and reenable the wifi. This works because the filter only turns on when the screen goes off, so starting wifi with the screen off will keep it working until the screen goes off again. This is what we did before we figured out solution (1).

阅读全文

相关推荐

最新文章