Example #1
0
        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());
        }
        // 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());
        }