具有更高意图的设备成为群组所有者,如下链接所述: http://developer.bada.com/help_2.0/index.jsp?topic=%2Fcom.osp.cppappprogramming.help%2Fhtml%2Fdev_guide%2Fnet%2Fwi-fi_direct_connectivity.htm
我在 wifi-direct 的 google-demo 项目中尝试了以下方法。 在调用广播接收器的主要事件类中,我在一台设备上运行时按如下方式设置优先级。
public void onResume() {
super.onResume();
receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
intentFilter.setPriority(999);
registerReceiver(receiver, intentFilter);
}
在下一个设备中运行代码时,我没有设置优先级。
public void onResume() {
super.onResume();
receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
registerReceiver(receiver, intentFilter);
}
因此根据链接,具有更高优先级的设备应该是组所有者,但设置优先级似乎不起作用。 有没有办法在两个设备之间建立连接时将特定设备明确指定为组所有者?
请您参考如下方法:
在你的connect方法中设置WifiP2pConfig对象的groupOwnerIntent,取值范围是0到15。 0 表示最不倾向于成为 GO,15 表示最倾向于成为 GO:
WifiP2pConfig config = new WifiP2pConfig();
config.groupOwnerIntent = 0; //Less probability to become the GO
config.deviceAddress = service.device.deviceAddress;
config.wps.setup = WpsInfo.PBC;