如何为WiFi Direct连接设置特定引脚?

时间:2015-01-15 09:08:11

标签: java android wifi-direct

尝试使用特定PIN码设置连接:

WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = assetWifiP2pDevice.deviceAddress;
config.wps.setup = WpsInfo.DISPLAY;
config.wps.pin = "00000000";
mManager.cancelConnect(mChannel, null);
mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
    @Override
    public void onSuccess() {
    }

    @Override
    public void onFailure(int reason) {
    }
});

但是在弹出连接对话框中,我看到随机生成的PIN。

在没有任何对话的情况下设置引脚和自动连接的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

我通过将设置更改为WpsInfo.KEYPAD

来实现此功能
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = assetWifiP2pDevice.deviceAddress;
config.wps.setup = WpsInfo.KEYPAD;
config.wps.pin = "00000000";
mManager.cancelConnect(mChannel, null);
mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
    @Override
    public void onSuccess() {
    }

    @Override
    public void onFailure(int reason) {
    }
});