Android、wifi主动扫描

发布于 2024-11-04 23:28:19 字数 174 浏览 2 评论 0原文

我需要在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

全部不再 2024-11-11 23:28:19

我一直在尝试同样的事情,并得出以下结论。在 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.

短暂陪伴 2024-11-11 23:28:19

我认为你不能。它是设备和/或操作系统版本相关的设置。例如,在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文