public IAsyncOperation <OnboardingConfigureWifiResult> ConfigureWifiAsync( AllJoynMessageInfo info, string interfaceMemberSSID, string interfaceMemberPassphrase, short interfaceMemberAuthType) { return(Task.Run(() => { // make sure a valid value is provided for auth type if (!Enum.IsDefined(typeof(AuthType), interfaceMemberAuthType)) { return OnboardingConfigureWifiResult.CreateFailureResult(AllJoynStatus.InvalidArgument3); } // May want to switch this to concurrent mode if possible: // "Concurrent step used to validate the personal AP connection. In this case, the Onboarder application must wait for the // ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link." _personalApSsid = interfaceMemberSSID; _personalApPassword = interfaceMemberPassphrase; _authType = (AuthType)interfaceMemberAuthType; lock (_stateLock) { _state = OnboardingState.ConfiguredNotValidated; } // Status "1" indicates the SoftAP will remain available until the Connect method is invoked return OnboardingConfigureWifiResult.CreateSuccessResult(1); }).AsAsyncOperation()); }
private async void AttemptOnboardingAsync(string ssid, string password, short authType) { if (string.IsNullOrWhiteSpace(ssid)) { UpdateStatusAsync("No SSID selected. Please select a network or manually enter SSID.", NotifyType.ErrorMessage); } else { UpdateStatusAsync("Attempting to configure onboardee...", NotifyType.StatusMessage); OnboardingConfigureWifiResult configureWifiResult = await m_consumer.ConfigureWifiAsync(ssid, password, authType); if (configureWifiResult.Status == AllJoynStatus.Ok) { UpdateStatusAsync("Onboardee sucessfully configured.", NotifyType.StatusMessage); if (configureWifiResult.Status2 == (short)ConfigureWiFiResultStatus.Concurrent) { // Concurrent step used to validate the personal AP connection. In this case, the Onboarder application must // wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. m_consumer.Signals.ConnectionResultReceived += Signals_ConnectionResultReceived; } AttemptConnectionAsync(); } else { UpdateStatusAsync(string.Format("Attempt to configure WiFi failed with AllJoyn error: 0x{0:X}.", configureWifiResult.Status), NotifyType.ErrorMessage); } } ClearPasswords(); }
// Method to handle calls to the ConfigureWifi method. IAsyncOperation <OnboardingConfigureWifiResult> IOnboardingService.ConfigureWifiAsync(AllJoynMessageInfo info, string interfaceMemberSsid, string interfaceMemberPassphrase, short interfaceMemberAuthType) { IAsyncAction asyncAction = MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MainPage.Current.NotifyUser("Configure WiFi request received", NotifyType.StatusMessage); }); Task <OnboardingConfigureWifiResult> task = new Task <OnboardingConfigureWifiResult>(() => { AppData.OnboardingConfigureSsid = interfaceMemberSsid; AppData.OnboardingConfigurePassphrase = interfaceMemberPassphrase; AppData.OnboardingConfigureAuthType = interfaceMemberAuthType; AppData.OnboardingConfigurationState = (short)ConfigurationState.NotValidated; return(OnboardingConfigureWifiResult.CreateSuccessResult((short)ConfigureWiFiResultStatus.Concurrent)); }); task.Start(); return(task.AsAsyncOperation()); }