'WiFiDirectDevice::FromIdAsync API returns null for already paired devices

Implemented C++/WinRT Console Application which uses similar implementation of Connector Scenario of WiFiDirect Sample.

Running the same application in both laptops, Pairing and connection is happening for the initial connection. If I initiate connection request when both laptops already paired, then FromIDAsyn() API is returning null, I had to connect multiple times to get proper WiFiDirectDevice object. I have read the MSDN and forums, but I did not find the how to get the reason for this issue.

        if (!devInfo.Pairing().IsPaired())
         {
             if (co_await RequestPairDeviceAsync(devInfo.Pairing()) == false)
             {
                 printf("WiFiDirectdevice: RequestPairDeviceAsync Failed");
                 co_return;
             }
         }

          WiFiDirectDevice wfdDevice = nullptr;
         try
         {
             wfdDevice = co_await WiFiDirectDevice::FromIdAsync(devInfo.Id());
             if (wfdDevice == nullptr) {
                 co_return;
             }
         }
         catch (hresult_canceled const&)
         {
             co_return;
         }

Queries:

  1. Why is FromIDAsyn() is returning null if though I am passing correct argument?
  2. How do I know the reason for this?
  3. Some forums suggested to use Proximity Capability in app manifest file, how can I do that with C++/WinRT Console application?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source