Exemplo n.º 1
0
        public IAsyncOperation <OnboardingGetScanInfoResult> GetScanInfoAsync(AllJoynMessageInfo info)
        {
            return(Task.Run(async() =>
            {
                var adapter = await WiFiAdapter.FromIdAsync(_wlanAdapterId);
                await adapter.ScanAsync();

                var availableNetworks = new List <OnboardingScanListItem>();
                foreach (var network in adapter.NetworkReport.AvailableNetworks)
                {
                    var listItem = new OnboardingScanListItem {
                        Value1 = network.Ssid
                    };

                    switch (network.SecuritySettings.NetworkAuthenticationType)
                    {
                    case NetworkAuthenticationType.Open80211:
                        {
                            listItem.Value2 = (short)AuthType.Open;
                            break;
                        }

                    case NetworkAuthenticationType.Wpa:
                        {
                            listItem.Value2 = (short)AuthType.WPA_AUTO;
                            break;
                        }

                    default:
                        {
                            listItem.Value2 = (short)AuthType.Any;
                            break;
                        }
                    }

                    if (availableNetworks.Find(x => x.Value1 == listItem.Value1 && x.Value2 == listItem.Value2) == null)
                    {
                        availableNetworks.Add(listItem);
                    }
                }

                return OnboardingGetScanInfoResult.CreateSuccessResult(0, availableNetworks);
            }).AsAsyncOperation());
        }
Exemplo n.º 2
0
        public IAsyncOperation<OnboardingGetScanInfoResult> GetScanInfoAsync(AllJoynMessageInfo info)
        {
            return Task.Run(async () =>
            {
                await _wlanAdapter.ScanAsync();

                var availableNetworks = new List<OnboardingScanListItem>();
                foreach (var network in _wlanAdapter.NetworkReport.AvailableNetworks)
                {
                    var listItem = new OnboardingScanListItem { Value1 = network.Ssid };

                    switch (network.SecuritySettings.NetworkAuthenticationType)
                    {
                        case NetworkAuthenticationType.Open80211:
                            {
                                listItem.Value2 = (short)AuthType.Open;
                                break;
                            }
                        case NetworkAuthenticationType.Wpa:
                            {
                                listItem.Value2 = (short)AuthType.WPA_AUTO;
                                break;
                            }
                        default:
                            {
                                listItem.Value2 = (short)AuthType.Any;
                                break;
                            }
                    }

                    if (availableNetworks.Find(x => x.Value1 == listItem.Value1 && x.Value2 == listItem.Value2) == null)
                    {
                        availableNetworks.Add(listItem);
                    }
                }

                return OnboardingGetScanInfoResult.CreateSuccessResult(0, availableNetworks);

            }).AsAsyncOperation();
        }