Android WiFi Direct 自动身份验证

发布于 2025-01-03 12:00:40 字数 399 浏览 4 评论 0原文

在Android ICS中,提供了无线P2P(WiFi Direct)API。

我尝试开发一个应用程序,如果 MAC 地址匹配,它可以通过无线 P2P 自动连接 2 部手机。

根据 SDK 文档,我必须执行以下步骤:

  1. 从“设置”中打开 WiFi Direct。
  2. 初始化P2P连接。 -initialize()
  3. 发现对等点。 - discoveryPeers()
  4. 查看 MAC 地址是否匹配。
  5. 连接到发现的对等点。 - connect()

一旦调用 connect() API,远端手机将弹出一个连接验证对话框。 (取决于 WifiP2pConfig)

是否可以自动连接,而无需 Farside 弹出对话框?

In Android ICS, Wireless P2P (WiFi Direct) API is provided.

I tried to develop an Application which can connect 2 phones via Wireless P2P automatically if the MAC address match.

From SDK documentation, I have to following steps:

  1. Turn on WiFi Direct from Setting.
  2. Initialize P2P connection. - initialize()
  3. Discover Peer. - discoverPeers()
  4. See if the MAC address matched.
  5. Connect to the discovered Peer. - connect()

Once, the connect() API is called, Farside phone will Pop Up a connection Authentication Dialog. (Depending on WifiP2pConfig)

Is there anyway to connect automatically, without having Farside to popup the Dialog?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

锦上情书 2025-01-10 12:00:40

看来身份验证对话的自动化是不可能的,这也使得 p2p 路由不可能。目前,WpsInfo 类(在对等连接期间传递到 WifiP2pManager 的 connect() 函数的 WifiP2pConfig 类中使用)仅以四种方式显示身份验证对话框:DISPLAY / KEYPAD / LABEL / PBC。我相信 PBC (按钮配置)是默认的,也是您所指的。其他三个选项要求用户输入一种引脚类型,这使得它们更无法用于自动连接。也许如果我们要找到此身份验证对话框类的类型,我们可以自动单击“确定”按钮?

我希望可以添加一个新选项,使应用程序能够验证连接而不是用户。这种基于用户的身份验证看起来像是从蓝牙 API 继承过来的,并且严重限制了 wifi direct 的实用性。也许谷歌的人可以帮助我们?

It seems that automation of authentication dialogs is not possible, and this makes p2p routing impossible as well. Right now, the WpsInfo class (which is used in the WifiP2pConfig class that gets passed into the WifiP2pManager's connect() function during peer connection) only displays authentication dialogs in four ways: DISPLAY / KEYPAD / LABEL / PBC. I believe that PBC (push button config ) is the default and is what you refer to. The other three options require the user to input a type of pin, making them even more unusable for automated connections. Maybe if we were to find the type of this authentication dialog class, we could automate the clicking of the 'ok' button?

I wish a new option could be added that would give the application the ability to authenticate a connection, rather than the user. This user based authentication looks like its been carried over from the bluetooth api, and severely limits the usefulness of wifi direct. Maybe the folks at google could help us out?

命硬 2025-01-10 12:00:40

与此同时,情况发生了变化。您可以使用 WifiP2pManager 的 creategroup() 全自动创建 wifi 直接连接,并使用 onGroupInfoAvailable() 获取随机生成的密码和 SSID,请参阅此说明示例代码

In the mean time the situation has changed. You can create a wifi direct connection fully automatic using creategroup() of the WifiP2pManager and the fetch the randomly generated password and SSID with onGroupInfoAvailable(), see this description with example code.

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