Mazze
Mazze

Reputation: 1404

Wi-Fi direct connecting issues

I'm trying to pair a device directly to another device using Android's own Wi-Fi direct interface.

However I have issues accepting the incoming group invitation from a similar device.

From the client I've managed to get this error:

09-16 13:42:07.547: E/WifiP2pService(511): Unhandled message { what=147487 when=-1ms     obj=network: null
09-16 13:42:07.547: E/WifiP2pService(511):  isGO: false
09-16 13:42:07.547: E/WifiP2pService(511):  GO: Device: 
09-16 13:42:07.547: E/WifiP2pService(511):  deviceAddress: *CENSORED*
09-16 13:42:07.547: E/WifiP2pService(511):  primary type: null
09-16 13:42:07.547: E/WifiP2pService(511):  secondary type: null
09-16 13:42:07.547: E/WifiP2pService(511):  wps: 0
09-16 13:42:07.547: E/WifiP2pService(511):  grpcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511):  devcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511):  status: 4
09-16 13:42:07.547: E/WifiP2pService(511):  wfdInfo: null
09-16 13:42:07.547: E/WifiP2pService(511):  Client: Device: 
09-16 13:42:07.547: E/WifiP2pService(511):  deviceAddress: *CENSORED*
09-16 13:42:07.547: E/WifiP2pService(511):  primary type: null
09-16 13:42:07.547: E/WifiP2pService(511):  secondary type: null
09-16 13:42:07.547: E/WifiP2pService(511):  wps: 0
09-16 13:42:07.547: E/WifiP2pService(511):  grpcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511):  devcapab: 0
09-16 13:42:07.547: E/WifiP2pService(511):  status: 4
09-16 13:42:07.547: E/WifiP2pService(511):  wfdInfo: null
09-16 13:42:07.547: E/WifiP2pService(511):  interface: null
09-16 13:42:07.547: E/WifiP2pService(511):  networkId: -2 }

The GO (group owner) connects using the following code:

WifiP2pConfig config = new WifiP2pConfig();
                    config.deviceAddress = device.deviceAddress;
                    config.groupOwnerIntent = 15;
                    config.wps.setup = WpsInfo.PBC;

                mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {

                    @Override
                    public void onSuccess() {

                        new FetchDeviceInfo().execute(device);

                    }

                    @Override
                    public void onFailure(int reason) {
                        // TODO Auto-generated method stub
                        Toast.makeText(getBaseContext(), "Failure to connect: " + reason, Toast.LENGTH_SHORT).show();


                    }
                });

And the Asynctask executing is just to fetch the client IP address.

Upvotes: 1

Views: 1193

Answers (1)

Bill G
Bill G

Reputation: 349

The protocol for negotiating the group owner will fail if both devices want to be the group owner (config.groupOwnerIntent == 15). Anything under has a tiebreaker bit if the GO intent is the same and will succeed.

The way I connect two devices (using your code) is as follows:

WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    Random r = new Random();
    config.groupOwnerIntent = r.nextInt(14);

    mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
    ...

Upvotes: 1

Related Questions