private async void OnScanUpdated(Signal signal) { WifiSignals.Clear(); OutputText = string.Empty; if (signal.WifiSignals != null && signal.WifiSignals.Count() > 0) { foreach (var s in signal.WifiSignals.OrderByDescending(s => s.NetworkRssiInDecibelMilliwatts)) { WifiSignals.Add(s); } // BasicGeoposition basicGeoPosition = new BasicGeoposition() { Latitude = signal.Geoposition.Coordinate.Point.Position.Latitude, Longitude = signal.Geoposition.Coordinate.Point.Position.Longitude }; // CurrentLocation = new Geopoint(basicGeoPosition);// signal.GeoPosition.Coordinate.Point; if (signal.Geoposition != null) { ActualCoordinates = $"Latitude: {signal.Geoposition.Coordinate.Point.Position.Latitude.ToString()}, Longitude: {signal.Geoposition.Coordinate.Point.Position.Longitude.ToString()}"; } await _TransferService.CommitToServer(signal); } else { OutputText = "No Wifi signals."; // + Environment.NewLine; } foreach (var e in signal.Errors) { OutputText += e; // + Environment.NewLine; } OutputText += string.Format($"(S: {_TransferService.GetSuspendedSignals()})"); }
public ScannerViewModel(ITransferService transferService) { ScanStartCommand = new RelayCommand(ExecuteScanStartCommand); GpsActiveCommand = new RelayCommand(ExecuteGpsActiveCommand); WlanActiveCommand = new RelayCommand(ExecuteWlanActiveCommand); _TransferService = transferService; if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { WifiSignals.Add(new WiFiSignal() { Ssid = "First net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -12d, NetworkKind = "Ccmp" }); WifiSignals.Add(new WiFiSignal() { Ssid = "Second net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -33, NetworkKind = "Ccmp" }); WifiSignals.Add(new WiFiSignal() { Ssid = "Third net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -54, NetworkKind = "Ccmp" }); WifiSignals.Add(new WiFiSignal() { Ssid = "Fourth net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -64, NetworkKind = "Ccmp" }); WifiSignals.Add(new WiFiSignal() { Ssid = "Fiveth net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -66, NetworkKind = "Ccmp" }); WifiSignals.Add(new WiFiSignal() { Ssid = "Sixth net", ChannelCenterFrequencyInKilohertz = 1, NetworkRssiInDecibelMilliwatts = -67, NetworkKind = "Ccmp" }); } _Scanner = new Scanner(); }
public async void ScanWifi() { using (_cancellationSource = new CancellationTokenSource()) { var id = Guid.NewGuid(); var parameters = new DialogParameters { { ScanningWifiParams.CancellationTokenSource, _cancellationSource }, { ScanningWifiParams.Identifier, id } }; _dialogService.ShowDialog(DialogConstants.ScanningWifi, parameters); var signals = (await _wifiService.GetWifiSignals(_cancellationSource.Token)) .Where(p => !string.IsNullOrWhiteSpace(p.Ssid)) .ToList(); var modules = signals.Where(p => p.Ssid.StartsWith(Device.SsidPrefix)) .OrderByDescending(p => p.Level) .ToList(); WifiSignals.Clear(); DeviceWifiSignals.Clear(); signals.ForEach(WifiSignals.Add); modules.ForEach(DeviceWifiSignals.Add); _eventAggregator.GetEvent <CloseDialogEvent>().Publish(id); } }
private void ExecuteScan() { _Scanner.ScanUpdated += OnScanUpdated; Scanning = !Scanning; if (Scanning) { _Scanner.StartScanner(); } else { _Scanner.StopScanner(); WifiSignals.Clear(); OutputText = string.Empty; ActualCoordinates = string.Empty; } }