private void ExecuteInternal() { try { // For non-pushbutton pairing, generate a new passkey and make sure both test controllers have it. if (configMethod != DOT11_WPS_CONFIG_METHOD.DOT11_WPS_CONFIG_METHOD_PUSHBUTTON) { remoteWFDController.PassKey = localWFDController.GenerateAndStoreNewPassKey(); } // Prepare the remote device to receive the connection request. remoteWFDController.AcceptNextGroupRequest( localWFDController.DeviceAddress, (pairingScenarioType == PairingScenarioType.GoNegotiationDutBecomesGo) ? ((byte)0) : ((byte)14), GetAcceptConfigMethod() ); // Begin by performing a targeted discovery for the remote device. bool discoverySucceeded = PerformTargetedDiscovery(); if (!discoverySucceeded) { return; } WFD_PAIR_WITH_DEVICE_PREFERENCE pairWithDevicePreference; switch (this.pairingScenarioType) { case PairingScenarioType.JoinExistingGo: pairWithDevicePreference = WFD_PAIR_WITH_DEVICE_PREFERENCE.WFD_PAIRING_PREFER_NONE; break; case PairingScenarioType.Invitation: pairWithDevicePreference = WFD_PAIR_WITH_DEVICE_PREFERENCE.WFD_PAIRING_PREFER_INVITATION; break; case PairingScenarioType.GoNegotiationDutBecomesGo: case PairingScenarioType.GoNegotiationDutBecomesClient: pairWithDevicePreference = WFD_PAIR_WITH_DEVICE_PREFERENCE.WFD_PAIRING_PREFER_GO_NEGOTIATION; break; default: throw new Exception("Cannot map pairing scenario to pairing preference."); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // Pair with the target device. WiFiDirectTestLogger.Log("Starting pairing with device {0} ({1})", remoteWFDController.DeviceAddress, remoteWFDController.MachineName); localWFDController.PairWithDevice( remoteWFDController.DeviceAddress, pairWithDevicePreference, (pairingScenarioType == PairingScenarioType.GoNegotiationDutBecomesClient) ? ((byte)0) : ((byte)14), configMethod, isPersistent ); WiFiDirectTestLogger.Log("Pairing successful", remoteWFDController.DeviceAddress, remoteWFDController.MachineName); stopwatch.Stop(); WiFiDirectTestLogger.Log("Pairing completed in {0} ms.", stopwatch.ElapsedMilliseconds); bool sessionStateValid = VerifySessionState(); if (!sessionStateValid) { return; } if (this.runDataPathValidation) { WiFiDirectTestUtilities.RunDataPathValidation(localWFDController, remoteWFDController); } succeeded = true; } catch (Exception e) { WiFiDirectTestLogger.Error("Caught exception while executing pairing scenario: {0}", e); } }