0

I want to require entering a PIN when connecting two Android devices to ensure they are talking to each other.

There is a sample project in the Android SDK 17 called "WiFiDirectDemo". It establishes a Wi-Fi Direct connection but it lacks the PIN authentication.

  1. I don't know how to specify WiFiP2pConfig.wps.setup in the class DeviceDetailFragment around line 71. Do I specify the action on the current device (I want to show a auto-generated four-digit PIN), i. e. config.wps.setup = WPSInfo.DISPLAY, or should I specify the action on the peer, i. e. config.wps.setup = WPSInfo.KEYPAD?
  2. How can I detect the connection request on the other peer? I guess there is something I can listen to, e. g. in the BroadcastReceiver, but I cannot find it.

I'm an experienced iOS developer but Android is very new to me, maybe the the answer is obvious to you. Thanks for your help.

4

2 回答 2

1

p2pconfig.wps.setup=WpsInfo.KEYPAD(不要指定p2pconfig.wps.pin)对我来说很好用。它在我们尝试连接的设备上显示一个动态生成的密钥,以便在其他设备上输入。

在这种情况下,您不需要监听任何 b'cast 接收器来检测连接。wpa_supplicant 会处理它并提示您输入 pin。为了清晰的图片,请查看 logcat(我使用 ADT 的 adb (sdk+eclipse) 在连接进行时查看 wpa_supplicant 的 logcat)。

于 2013-06-27T09:55:32.960 回答
1

您需要在发送连接请求的设备上指定操作...对于引脚,我认为这应该可以

p2pconfig.wps.setup = WpsInfo.DISPLAY;p2pconfig.wps.pin = "0000"; 连接时,PIN 显示在本地设备上,并要求用户在远程设备上输入相同的 PIN;输入 PIN 后,连接成功完成。

检查此https://groups.google.com/forum/#!topic/android-platform/hN5WfXRzXp我阅读了第 5 篇文章

于 2013-06-27T05:53:02.837 回答