Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a specific group owner in Wifi-Direct Android

I have an Wifi Direct Android Application which will run on two Phones.

When phone1 connects to phone2 , I want phone1 to act as a client and phone2 to act as a server.

I used this code:

if (info.groupFormed && info.isGroupOwner) {

           // start the server thread

   } else if (info.groupFormed) {

            // start the client thread
   }

But the problem is that , sometimes phone1 which has initiated the connection and I want it to act as a client , it sometimes acts as a GroupOwner, and the server thread is started on the client phone.

I want to make sure that phone2 always act as a GroupOwner and a server.

like image 890
Hammad Shahid Avatar asked Sep 09 '13 17:09

Hammad Shahid


People also ask

What is group owner in Wi-Fi Direct?

The group owner election is established through the group owner negotiation procedure, where devices exchange their Intent Value, which represents their willingness to act as a group owner. The device with a higher Intent Value is elected to be a group owner.

What is a Wi-Fi Direct Group?

Wi-Fi Direct (also known as peer-to-peer or P2P) allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth. The Wi-Fi Direct (P2P) APIs allow applications to connect to nearby devices without needing to connect to a network or hotspot.

Can anyone connect to my Wi-Fi Direct?

The device supported Wi-Fi Direct as standard, and it was automatically enabled, allowing anyone within range to connect.

How does Wi-Fi Direct work on Android?

How Does Wi-Fi Direct Work? Wi-Fi Direct doesn't require a centralized network or wireless router to share information between devices. Instead, when a connection is made, one device acts as the access point or hotspot. Other devices then connect to this original device using WPS and WPA/WPA2 protocols.


1 Answers

To set a peer as a client , not a GroupOWner eachtime , we have to assign:

config.groupOwnerIntent = 0;
like image 192
Hammad Shahid Avatar answered Sep 29 '22 10:09

Hammad Shahid