Android、wifi主动扫描
我需要在我的 Android 应用程序上进行频繁的 wifi 扫描(我正在尝试基于 wifi RSSI 值构建本地室内定位系统)。如果我调用 wifi.startScan() 我有 onReceive() 每 6 秒回调一次(我想默认情况下它是被动扫描):如何获得更频繁的回调?我应该要求“主动”扫描吗?它是如何完成的?有什么缺点吗?
I need a frequent wifi scan on my android application (I'm trying to build a local indoor positioning system based on wifi RSSI values). IF I call wifi.startScan() I have onReceive() called back once every 6 seconds (I suppose by default it's scanning passively): how do I get more frequent callbacks? Should I ask for "active" scans? How is it done? Are there any drawbacks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在尝试同样的事情,并得出以下结论。在 2.1 及更高版本上这是不可能的。我对较低版本一无所知,因为我的应用程序必须在 2.1 及更高版本上运行。
-更改了 Android SDK 内部的内容,以便启用主动扫描
-将其追溯到驱动程序,得出以下结论:
驱动程序每次都会将wifi模块设置为被动模式。我一直在寻求在驱动程序内部更改此设置,但驱动器内部没有设置来实现此目的。
底线:
不可能。
I've been trying the same thing and I came to the following conclusion. It's not possible on 2.1 and higher. I've got no clue on lower versions because my app had to run on 2.1 and higher.
-Changed stuff inside the Android SDK so it will enable active scanning
-Traced it back to the driver resulting in the following conclusion:
The driver will set the wifi module in passive mode every time. I've been looking to change this inside the driver but there was no setting inside the drive to achieve this.
Bottom line:
Not possible.
我认为你不能。它是设备和/或操作系统版本相关的设置。例如,在 Nexus One 上,扫描大约需要一秒钟,而在 G1 上,则需要更长的时间(或者在几次扫描后获得新结果)。如果我没记错的话,某些 Android 版本(<2.0)不会在每次调用
startScan()
时发出新的扫描,但可能会重用旧的结果。但我可能在这一点上弄错了。I don't think you can. It is a device and/or OS version dependend setting. On the Nexus One for example it takes roughly a second to scan whereas on the G1 it takes significantly longer (or get fresh results after a few scans). If I recall correctly, some Android Version (< 2.0) did not issue a fresh scan everytime
startScan()
was called but might have reused the old result. But I might be mistaken on that one.