所以幾個月前我開始開發一些WiFi-Direct應用程序。幾天前,我將兩個Galaxy Nexus都更新爲Jelly Bean(4.1.x)並測試了我的應用程序,但似乎又有些東西被搞砸了。爲了獲得主要的功能已經很痛苦在ICS上,但現在它不再工作了。WiFi-Direct上JellyBean,WPA Supplicant搞砸了
我得到的是這樣的事情在我的logcat:
/wpa_supplicant( 392): p2p0: P2P-PROV-DISC-PBC-REQ a2:0b:ba:xy:zz:xx p2p_dev_addr=a2:0b:ba:xy:zz:xx pri_dev_type=10-0050F204-x name='Android_e9f0' config_methods=0x188 dev_capab=0x27 group_capab=0x0
I/wpa_supplicant( 392): p2p0: P2P-DEVICE-FOUND a2:0b:ba:xy:zz:xx p2p_dev_addr=a2:0b:ba:xy:zz:xx pri_dev_type=10-0050F204-5 name='Android_e9f0' config_methods=0x188 dev_capab=0x27 group_capab=0x0
I/wpa_supplicant( 392): p2p0: P2P-GO-NEG-REQUEST a2:0b:ba:xx:zz:xy dev_passwd_id=4
I/wpa_supplicant( 392): p2p0: P2P-FIND-STOPPED
I/wpa_supplicant( 392): p2p0: P2P-GO-NEG-FAILURE status=7
W/Netd ( 120): No subsystem found in netlink event
D/NetlinkEvent( 120): Unexpected netlink message. type=0x11
I/wpa_supplicant( 392): p2p0: P2P-DEVICE-LOST p2p_dev_addr=a2:0b:ba:xx:zz:xy
I/wpa_supplicant( 392): p2p0: P2P-DEVICE-FOUND a2:0b:ba:xx:zz:xy p2p_dev_addr=a2:0b:ba:xx:zz:xy pri_dev_type=10-0050F204-5 name='Android_e9f0' config_methods=0x188 dev_capab=0x27 group_capab=0x0
的「邀請對話」的第二個電話正常彈出,和「有時」(隨機),它甚至還可以,但只有在每第五次嘗試什麼的。所以logcat告訴我,因爲我不是專業的android實習生代碼,談判簡單地失敗了,設備在短時間內迷路了,然後又被發現了,似乎所有的東西都搞砸了。
我的邀請被髮送出去這樣的:
public void onPeersAvailable(WifiP2pDeviceList peers) {
if (isInvitationSent)
return;
for (WifiP2pDevice dev : peers.getDeviceList()) {
WifiP2pConfig c = new WifiP2pConfig();
c.deviceAddress = dev.deviceAddress;
c.wps.setup = WpsInfo.PBC;
if (initiator
&& !isInvitationSent
&& WiFiSupport.compareMacAddressesInsensitive(MAC_ADDRESS,
dev.deviceAddress)) {
isInvitationSent = true;
sendInvitation(c);
}
}
}
private void sendInvitation(final WifiP2pConfig config) {
log("Sending invitation to " + config.deviceAddress);
mWifiManager.connect(mChannel, config, new ActionListener() {
@Override
public void onSuccess() {
log("Invitation sent!");
}
@Override
public void onFailure(int reason) {
log("Invitation failed!");
Toast.makeText(getApplicationContext(), "Could not connect to peer, reason:"+reason, Toast.LENGTH_LONG).show();
if (!retryChannel) {
log("Retrying to send invitation.");
retryChannel = true;
sendInvitation(config);
}
}
});
}
我讀了很多的WIFI直接在Android上,和它一直工作正常,直到我更新了手機果凍豆..任何人都知道,是什麼可能是錯的?如果您需要更多的代碼示例或代碼的任何特定部分,請告訴我,因爲我不知道什麼是可靠的。
謝謝你的幫助。
編輯:
改變了WifiP2pConfig.wps.setup方法爲「顯示」時,這導致設備#1顯示PIN代碼,設備#2彈出一個對話框,輸入字段 - 在輸入正確的後引腳這是什麼logcat的告訴我說:
08-31 15:13:28.241: I/wpa_supplicant(384): p2p0: P2P-GO-NEG-SUCCESS
08-31 15:13:28.241: I/wpa_supplicant(384): rfkill: Cannot open RFKILL control device
08-31 15:13:29.850: W/wpa_supplicant(384): p2p-p2p0-3: Could not connect to kernel driver
08-31 15:13:30.264: E/wpa_supplicant(384): Using interface p2p-p2p0-3 with hwaddr a2:0b:ba:x:y:z and ssid 'DIRECT-ps-Android_e9f0'
08-31 15:13:30.491: I/wpa_supplicant(384): p2p-p2p0-3: CTRL-EVENT-CONNECTED - Connection to a2:0b:ba:x:y:z completed (auth) [id=0 id_str=]
08-31 15:13:43.491: I/wpa_supplicant(384): p2p0: P2P-GROUP-FORMATION-FAILURE
08-31 15:13:43.491: I/wpa_supplicant(384): p2p0: P2P-GROUP-REMOVED p2p-p2p0-3 GO
08-31 15:13:43.491: W/wpa_supplicant(384): p2p-p2p0-3: Could not connect to kernel driver
08-31 15:13:44.061: E/wpa_supplicant(384): Failed to remove interface (ifidx=15)
08-31 15:13:44.178: W/Netd(120): No subsystem found in netlink event
08-31 15:13:44.178: D/NetlinkEvent(120): Unexpected netlink message. type=0x11
08-31 15:13:44.248: W/Netd(120): No subsystem found in netlink event
08-31 15:13:44.248: D/NetlinkEvent(120): Unexpected netlink message. type=0x11
08-31 15:13:44.280: I/wpa_supplicant(384): p2p0: P2P-DEVICE-LOST p2p_dev_addr=a2:0b:ba:x:y:z
08-31 15:13:46.155: I/wpa_supplicant(384): p2p0: P2P-DEVICE-FOUND a2:0b:ba:x:y:z p2p_dev_addr=a2:0b:ba:x:y:z pri_dev_type=10-0050F204-5 name='Android_755f' config_methods=0x188 dev_capab=0x27 group_capab=0x0
有趣的是: 08-31 15:13:43.491:W /的wpa_supplicant(384):P2P-p2p0-3:無法連接到內核驅動程序
我想。看起來像Android自己的wifi-direct-framework中的一個bug對我來說?
看起來像小組的形成只會失敗,如果你在另一個WiFi網絡,如在你的家庭WiFi或類似的,所以Android無法禁用它 - 因此無法通過WiFi Direct連接。 – damian
你有沒有找到解決方案? – Zach
我開發了兩個HTC One Vs(由於ram限制無法更新爲果凍豆)以及HTC One X +(擁有4.1)。根據我的經驗,One Vs大部分時間都在工作,因爲One X +會更頻繁地失敗。 – Chucky