public void ConnectASPOverExistingP2PGroup() { using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController)) { // Start by doing WFD pairing // NOTE: use invitation (not used for services) and config method push button (not used for services) ExecutePairingScenario(PairingScenarioType.Invitation, DOT11_WPS_CONFIG_METHOD.DOT11_WPS_CONFIG_METHOD_PUSHBUTTON); // Make sure we close this session on cleanup needToCloseSession = true; // Connect, auto accept string serviceName = remoteWFDController.GenerateUniqueServiceName(); ServicesPublishDiscoverConnectParameters connectParams = new ServicesPublishDiscoverConnectParameters( serviceName, new ServicesConnectOptions(validateData: true) ); var pairResults = ExecutePublishDiscoverConnectScenario(connectParams); Verify.AreEqual(1, pairResults.ConnectResults.Count); // Disconnect ExecuteDisconnectScenario( new ServicesDisconnectParameters( pairResults.ConnectResults[0].AdvertiserSessionHandle, pairResults.ConnectResults[0].SeekerSessionHandle ), false ); // WFD connection should stay up WiFiDirectTestLogger.Log("Closed ASP Session, waiting to make sure WFD session stays active..."); Task.Delay(8000).Wait(); WfdGlobalSessionState globalSessionStateLocal = localWFDController.QueryGlobalSessionState(); if (globalSessionStateLocal.Sessions.Length != 1) { WiFiDirectTestLogger.Error("Expected a single active session. Current session count = {0}", globalSessionStateLocal.Sessions.Length); throw new Exception("Local machine session is closed"); } WiFiDirectTestUtilities.RunDataPathValidation(localWFDController, remoteWFDController, "6001"); // Close WFD connection localWFDController.CloseSession(); needToCloseSession = false; } }
private bool VerifySessionState() { WfdGlobalSessionState globalSessionState = localWFDController.QueryGlobalSessionState(); if (globalSessionState.Sessions.Length != 1) { WiFiDirectTestLogger.Error("Expected a single active session. Current session count = {0}", globalSessionState.Sessions.Length); return(false); } WFD_ROLE_TYPE expectedRole; switch (pairingScenarioType) { case PairingScenarioType.Invitation: case PairingScenarioType.GoNegotiationDutBecomesGo: expectedRole = WFD_ROLE_TYPE.WFD_ROLE_TYPE_GROUP_OWNER; break; case PairingScenarioType.GoNegotiationDutBecomesClient: case PairingScenarioType.JoinExistingGo: expectedRole = WFD_ROLE_TYPE.WFD_ROLE_TYPE_CLIENT; break; default: throw new Exception("Unable to map pairing scenario type to role type."); } if (globalSessionState.Sessions[0].Role != expectedRole) { WiFiDirectTestLogger.Error("DUT became the WFD {0}. Expected {1}", MapRoleToString(globalSessionState.Sessions[0].Role), MapRoleToString(expectedRole)); return(false); } return(true); }