kinjal patel
kinjal patel

Reputation: 396

How to connect to specific Wifi direct Mac address

I have 2 devices and both support Wifi Direct. I want to turn on Wifi direct in both devices and connect to other device from 1st device by getting it's MAC address programmatically.

However, I'm able to list down nearby Wifi Direct devices in my application and make a connection using WifiP2PDevice object which Android provides in callback of peers list using WifiP2P APIs, but here my approach is to construct WifiP2PDevice object by using remote device MAC address directly and trying to connect it with no luck.

Can anyone help me in resolving this issue?

Upvotes: 0

Views: 1686

Answers (1)

JAD
JAD

Reputation: 1160

To connect to any device via wifi-direct, each device need to discover nearby peers or services before attempting to connect to make sure that wifi-direct is enabled and discoverable.

From my tests, even if you have the correct MAC address, trying to connect will not work unless peers or services discovery is executed and the device that you are looking for is discoverable / visible.

If the device is discoverable, you can create new WifiP2PDevice or reuse what's returning from the peers list and connect to it.

I hope I got your question correctly. If not, I'm happy to help if you explain further. Goodluck.

Upvotes: 1

Related Questions