How to Change the Group Owner in a Persistent Group in Wi-Fi Direct

WiFi Direct reassigning Group Owner during ongoing connection

You can not change the GO on active connections, thus yes, you do need to disconnect all devices first.

If you have a logic to determine which one is going to be the GO, then I would suggest using CreateGroup function to create the GO, and have others to connect to it once they see it advertising its presence.

How to add a device to a WifiP2pGroup in Android

You'd use one device to createGroup and then use the other devices to discoverPeers and requestPeers.

When onPeersAvaiable, You'd then iterate through the WifiP2pDevice's and call the isGroupOwner method on each device.

For each group owner address obtained, the client would then connect to the group owner.

Once a connection has been established, you would call requestConnectionInfo.

When onConnectionInfoAvailable you would check the WifiP2pInfo object to ensure the groupFormed boolean was true.

Then, using the groupOwnerAddress InetAddress, You can use Java Sockets to send signals between the two.

You could then send a string to the group owner saying 'BLAH BLAH BLAH UNIQUE VALUE'. If the group owner returns 'I UNDERSTAND' then you know the group owner belongs to your application. I the group owner returns anything else, or does not reply, then you know the group owner is invalid.

If you are using API 16+, you can use Service discovery to check whether a device is running your app, and THEN connect.



Related Topics



Leave a reply



Submit