Subash Basnet
Subash Basnet

Reputation: 305

setting group owner in android wifi direct

Device with the higher intent becomes the group owner is said in the following link: http://developer.bada.com/help_2.0/index.jsp?topic=%2Fcom.osp.cppappprogramming.help%2Fhtml%2Fdev_guide%2Fnet%2Fwi-fi_direct_connectivity.htm

I tried the following in the google-demo project of wifi-direct. In the main activity class from where broadcast receiver was called I set the priority as follows while running in one device.

public void onResume() {
    super.onResume();
    receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
    intentFilter.setPriority(999);
    registerReceiver(receiver, intentFilter);
}

While running the code in next device I didn't set the priority.

public void onResume() {
    super.onResume();
    receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);        
    registerReceiver(receiver, intentFilter);
}

So as per the link the device with the higher priority should have been the group owner but setting priority does not seem working. Is there a way to explicitly assign a particular device as the group owner while connection establishes between two devices ?

Upvotes: 2

Views: 9033

Answers (3)

misterbaykal
misterbaykal

Reputation: 542

First of all the link you provided is for bada phones. I don't know much about that operating system but it is possible that assigning could be different.

Anyhow, you can manually assign intent value for any device you want. For instance let's say you want to set the user who clicked connect button as a group owner. By definition, group owner should have the highest inclination which means greater than 0. Check this link.

To assign a peer as group owner, simply assign it to 15

config.groupOwnerIntent = 15;

Upvotes: 3

user3493629
user3493629

Reputation: 33

when I connect to remote device with config.groupOwnerIntent = 0, does it mean my device will be the group owner or the remote device would be the group owner?

Your device with config.groupOwnerIntent = 0 should become the client given that the intent value of the remote device is greater than 0 . If both the devices have same intent value then the tie breaker comes into picture. "Greater the intent value greater the chance of becoming GO" .We cannot simply make a device to act as a group owner by setting the intent value to zer0.It depends on the intent value of the other connecting device too.

Upvotes: 0

feisal
feisal

Reputation: 603

In your connect method set the groupOwnerIntent of the WifiP2pConfig object, the value range is 0 to 15. 0 indicates the least inclination to be a GO and 15 indicates the highest inclination to be a GO:

WifiP2pConfig config = new WifiP2pConfig();

    config.groupOwnerIntent = 0;  //Less probability to become the GO
    config.deviceAddress = service.device.deviceAddress;
    config.wps.setup = WpsInfo.PBC;

Upvotes: 5

Related Questions