question

LILIU-9315 avatar image
0 Votes"
LILIU-9315 asked RoyLi-MSFT commented

I use PairAsync method to pair another WIFIDirect device by C++, but I can not get "PairingRequested" callback after I push OK button on another device's screen.

       WiFiDirectConnectionParameters connctionParameter = WiFiDirectConnectionParameters();
       connctionParameter.GroupOwnerIntent(0);
       DevicePairingKinds devicePairingKinds = DevicePairingKinds::None;
       connctionParameter.PreferenceOrderedConfigurationMethods().Append(WiFiDirectConfigurationMethod::PushButton);
       devicePairingKinds |= WiFiDirectConnectionParameters::GetDevicePairingKinds(WiFiDirectConfigurationMethod::PushButton);
       connctionParameter.PreferredPairingProcedure(WiFiDirectPairingProcedure::Invitation);
       DeviceInformationCustomPairing customPairing = pairing.Custom();
       event_token token = customPairing.PairingRequested({ this, &WifiDirectClient::PairingRequestedHandler });
       IAsyncOperation<DevicePairingResult> pairingOperation = customPairing.PairAsync(devicePairingKinds, DevicePairingProtectionLevel::None, connctionParameter);
       AsyncStatus pairStatus = pairingOperation.wait_for(TimeSpan(PAIR_TIMEOUT));
       if (pairStatus != AsyncStatus::Completed) {
           if (pairStatus == AsyncStatus::Started) {
               pairingOperation.Cancel();
           }
           return false;
       }
       DevicePairingResult result = pairingOperation.GetResults();
       if (result == nullptr) {
           qDebug() << "result is null";
           return false;
       }
       if (result.Status() != DevicePairingResultStatus::Paired && result.Status() != DevicePairingResultStatus::AlreadyPaired) {
           return false;
       }
       return true;
        
        
        
        
   void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
   {
       DevicePairingKinds kind = args.PairingKind();
       qDebug() << "PairingRequestedHandler : ";
       if (kind == DevicePairingKinds::ConfirmOnly) {
           args.Accept();
       }else {
           qDebug() << "not support pairing kind";
       }
   }


I use PairAsync method to pair another WIFIDirect device by C++, but I can not get "PairingRequested" callback after I push OK button on another device's screen.
wait_for() operation timeout, the errorcode is 0, status is 0.
I can see the confirm dialog pop out on another device screen. And then I push the OK button. But pairasync operation timeout, the errorcode is 0, status is 0.
I also used get() method instead of wait_for(), but pairasync will not return.

windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I noticed that you've already posted the same question before and someone is waiting for your response. Please do not post the same question again and please focus on your pervious one.

0 Votes 0 ·

0 Answers