Persistent WifiDirect P2P connection?

Jason 1 Reputation point
2020-07-17T16:02:21.757+00:00

I am relatively new to UWP / WifiDirect. Using the Microsoft UWP "WifiDirect" c# sample application (win 10), I am able to pair a Wifi Direct device and also open a socket and communicate across it. Works great. When the pairing is established I can see that a virtual network adapter is created. While it exists, I can also ping the device.

When the application closes, the virtual network adapter goes away. The DeviceWatcher can still find the device and observes that the IsPaired state of the device it true. Pinging is not successful at this point, probably because the virtual adapter is gone.

I then fire up a new application session. I verify that the DeviceWatcher reports that the device is still paired. I then attempt to use WiFiDirectDevice.FromIdAsync() to get handle on the already paired device. The call always fails.

So the questions are:
Is there a way to make a persistent P2P connection so that the virtual adapter does not go away when the application closes? If so, what parameter or setting allows this?
If it is not possible, what is the proper mechanism by which a software session can obtain a handle on a device that is currently paired with the PC?

Is this even possible?

Currently I have to unpair and then re-pair in order to successfully obtain a new WifiDirectDevice object. Unfortunately, the documentation is sparse.

Here is a reference to the MS sample app mentioned above:

https://learn.microsoft.com/samples/microsoft/windows-universal-samples/wifidirect/

Universal Windows Platform (UWP)
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.