我正在尝试使用 Android 自己的 Wi-Fi 直接接口将设备直接与另一台设备配对。
但是,我在接受来自类似设备的传入群组邀请时遇到问题。
从客户端我设法得到这个错误:
09-16 13:42:07.547: E/WifiP2pService(511): Unhandled message { what=147487 when=-1ms obj=network: null
09-16 13:42:07.547: E/WifiP2pService(511): isGO: false
09-16 13:42:07.547: E/WifiP2pService(511): GO: Device:
09-16 13:42:07.547: E/WifiP2pService(511): deviceAddress: *CENSORED*
09-16 13:42:07.547: E/WifiP2pService(511): primary type: null
09-16 13:42:07.547: E/WifiP2pService(511): secondary type: null
09-16 13:42:07.547: E/WifiP2pService(511): wps: 0
09-16 13:42:07.547: E/WifiP2pService(511): grpcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511): devcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511): status: 4
09-16 13:42:07.547: E/WifiP2pService(511): wfdInfo: null
09-16 13:42:07.547: E/WifiP2pService(511): Client: Device:
09-16 13:42:07.547: E/WifiP2pService(511): deviceAddress: *CENSORED*
09-16 13:42:07.547: E/WifiP2pService(511): primary type: null
09-16 13:42:07.547: E/WifiP2pService(511): secondary type: null
09-16 13:42:07.547: E/WifiP2pService(511): wps: 0
09-16 13:42:07.547: E/WifiP2pService(511): grpcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511): devcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511): status: 4
09-16 13:42:07.547: E/WifiP2pService(511): wfdInfo: null
09-16 13:42:07.547: E/WifiP2pService(511): interface: null
09-16 13:42:07.547: E/WifiP2pService(511): networkId: -2 }
GO(组所有者)使用以下代码进行连接:
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.groupOwnerIntent = 15;
config.wps.setup = WpsInfo.PBC;
mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
new FetchDeviceInfo().execute(device);
}
@Override
public void onFailure(int reason) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "Failure to connect: " + reason, Toast.LENGTH_SHORT).show();
}
});
而执行的 Asynctask 只是为了获取客户端 IP 地址。