I'm trying to create tool that will support automative tests with many devices at the same time, where devices should react on others actions(Action and reaction). The first one that will launch tests should be Master, and every next one becomes client. Here are my question:
Can i use WifiP2pManager.createGroup()
method to make first device become Master, and the others to become Clients? I mean something like this:
manager.createGroup(channel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
//becomes Master
}
@Override
public void onFailure(int reason) {
//fails because group already exists, becomes Client
}
});
Is it possible for Client to get group info without previous discoverPeers and connect call? So i could do something like this:
manager.requestGroupInfo(DriverWifiP2PManager.getInstance().getChannel(), new WifiP2pManager.GroupInfoListener() {
@Override
public void onGroupInfoAvailable(WifiP2pGroup group) {
//i could see group, and if i'm not an owner i could connect to group owner device
}
});
Do i need to call connect on both side to join p2p group?
Thanks for your time.
Yes you can, basically the device that creates the group, becomes Group owner, which others can connect as clients.
If I understand the question right, the answer is No. after the group is created, the Group owner must also add locals service to advertise the group, and then clients, use normal discovery methods to find the group owner, and then connect to the group normally.
You only need to call connect from the client. Do note that you