为什么发现Android Wi-Fi Direct的对等方如此不可靠? [英] Why is discovering peers for Android Wi-Fi Direct so unreliable?

查看:111
本文介绍了为什么发现Android Wi-Fi Direct的对等方如此不可靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Android的Wi-Fi Direct(如果愿意,可以使用P2P).我以为两部手机之间的通话效果很好,但是我意识到我遇到了WifiP2pManager.discoverPeers()和/或WifiP2pManager.requestPeers()的问题.我观察到了以下结果:

I am experimenting with Android's Wi-Fi Direct (or P2P if you prefer). I thought it was working very nicely between my two phones, but I realized I am encountering issues with the WifiP2pManager.discoverPeers() and/or WifiP2pManager.requestPeers(). I have observed these results:

  • 在良好的1分钟以上时间内,未发现任何对等方,也未触发任何回调.我也通过Android Wi-Fi设置的Wi-Fi Direct部分进行了观察.这很奇怪,因为有时发现几乎立即完成.

  • No peers are discovered and no callbacks are fired for a good 1+ minute. I observe this through the Wi-Fi Direct portion of the Android Wi-Fi settings as well. This is odd because sometimes the discovery completes almost immediately.

我在手机A旁边有一个Roku设备和手机B.当所有设备都连接到我的Wi-Fi时,Roku只会在大约10%的时间内出现,而手机A和B却会彼此出现

I have a Roku device and phone B sitting next to phone A. While all are connected to my Wi-Fi, the Roku only appears ~10% of the time, while phones A and B appear to each other.

当我断开两部手机与所有Wi-Fi的连接并进行另一次扫描时,Roku出现了(!!!),但手机B直到我刷新至少十次才出现.

When I disconnected the two phones from all Wi-Fi and did another scan, the Roku showed up (!!!) but phone B did not until I had refreshed at least ten times.

我的两部手机是Nexus 7(运行4.4.4)和Nexus 5(运行5.0).

My two phones are a Nexus 7 (running 4.4.4) and a Nexus 5 (running 5.0).

推荐答案

我能够每10秒请求一次对等设备发现,以解决"某些电话未出现的问题.我想我遇到了这个问题,因为一个电话始终是主机,并且我不费心让它发现对等体(因为它不尝试加入他们的行列),并且Wifi Direct即将在该主机电话上入睡.我对同级结果不做任何事情,但是它唤醒了Wifi Direct系统.可能有更好的调用方法,但是我不确定它是什么.如果我不得不猜测,我会说我在浪费一些电池寿命.

I was able to "solve" the problems of some phones not appearing by requesting peer discovery every 10 seconds. I think I was running into this because one phone was always the host and I didn't bother to have it discover peers (because it doesn't try to join them), and the Wifi Direct was going to sleep on the host phone. I don't do anything with the peer results, but it wakes up the Wifi Direct system. There's probably a better method to call but I'm not sure what it is. If I had to guess I'd say I'm wasting some battery life.

这篇关于为什么发现Android Wi-Fi Direct的对等方如此不可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆