android和Linux之间的Wi-Fi直连

android和Linux之间的Wi-Fi直连,android,c,linux,wifi-direct,Android,C,Linux,Wifi Direct,我在使用Android连接linux时遇到了一个小问题 在我的Linux上:我使用: p2p_find p2p_peers p2p_prov_disc <ANDROID:MAC> keypad 在我的日志上,我得到: Click Connection : code :44779443 Connection to: 00:e0:4c:61:0f:d0 2 Connection failed 我的Linux上的ifconfig:HWaddr 00:e0:4c:61:0f:d0 我是

我在使用Android连接linux时遇到了一个小问题

在我的Linux上:我使用:

p2p_find
p2p_peers
p2p_prov_disc <ANDROID:MAC> keypad
在我的日志上,我得到:

Click Connection :
code :44779443
Connection to: 00:e0:4c:61:0f:d0
2
Connection failed
我的Linux上的ifconfig:
HWaddr 00:e0:4c:61:0f:d0

我是Android新手,我不知道是否不能打印出一个“errno”来响应我的失败代码。我在类中没有看到回调函数失败连接的接口

编辑:我还尝试了
config.wps.setup=WpsInfo.KEYPAD我认为它更准确

编辑:我很蠢,效果很好,只是我按了两次连接按钮(是的,我以为我搞错了事件管理的某个地方)。
所以我现在使用PBC方法:

config.wps.setup = WpsInfo.PBC;
config.groupOwnerIntent = 0;
之后,我创建了一个套接字:

new Thread(new Runnable() {
    @Override
    public void run() {
        try {
        Socket socket = new Socket("192.168.0.1", 4242);
        if (socket.isConnected())
        {
            System.out.println("Connection ok");
        }
        else
            System.out.println("connection failed");
        }catch (IOException e)
        {
             System.out.println(e);
        }

    }
}).start();
但我得到了:
java.net.ConnectException:无法连接到/192.168.0.1(端口4242):连接失败:无法访问网络)

为什么在我的c程序中基本上我做了:

-> connection to wpa_supplicant using wpa_ctrl.c
-> PING REQUEST to wpa_supplicant, reponse : PONG
-> P2p find
-> socket, bind , listen... No error return
-> p2p peer FIRST ( i dont manage all device for now)
-> p2p_prov_disc MAC::address pbc
-> using Select for checking Connection for accept
如果连接成功,为什么网络无法访问? 当我点击连接时,我会在PeersAvailable和OnConnectionInfoAvailable上使用callack函数

-> connection to wpa_supplicant using wpa_ctrl.c
-> PING REQUEST to wpa_supplicant, reponse : PONG
-> P2p find
-> socket, bind , listen... No error return
-> p2p peer FIRST ( i dont manage all device for now)
-> p2p_prov_disc MAC::address pbc
-> using Select for checking Connection for accept