private void WifiService_CheckingConnectionStatusUpdated(object sender, Common.WiFi.CheckingConnectionStatusUpdatedEventArgs e) { if (e.IsConnected && DeviceSetupService.SSIDIsEdisonDevice(deviceSetupService.CurrentDeviceHotspotNetwork.SSID)) { refreshAvailableNetworksTimer = new System.Timers.Timer(5000); refreshAvailableNetworksTimer.Elapsed += HandleRefreshTimerElapsed; refreshAvailableNetworksTimer.Start(); } }
private void WifiService_CheckingConnectionStatusUpdated(object sender, Common.WiFi.CheckingConnectionStatusUpdatedEventArgs e) { if (e.IsConnected) { if (DeviceSetupService.SSIDIsEdisonDevice(e.SSID)) { onboardingRestService.SetBasicAuthentication(deviceSetupService.PortalPassword); Task.Run(async() => { var networks = await this.onboardingRestService.GetAvailableWifiNetworks(); if (networks != default(IEnumerable <Models.AvailableNetwork>)) { var connectedNetwork = networks.FirstOrDefault(i => i.AlreadyConnected); if (connectedNetwork != default(Models.AvailableNetwork)) { this.wifiService.CheckingConnectionStatusUpdated -= WifiService_CheckingConnectionStatusUpdated; this.deviceSetupService.ConnectedWifiSSID = connectedNetwork.SSID; CheckingConnectionStatusUpdated?.Invoke(this, new CheckingConnectionStatusUpdatedEventArgs(connectedNetwork.SSID)); } else { this.wifiService.CheckingConnectionStatusUpdated -= WifiService_CheckingConnectionStatusUpdated; CheckingConnectionStatusUpdated?.Invoke(this, new CheckingConnectionStatusUpdatedEventArgs("Device Not Using WiFi")); } } else { this.wifiService.CheckingConnectionStatusUpdated -= WifiService_CheckingConnectionStatusUpdated; CheckingConnectionStatusUpdated?.Invoke(this, new CheckingConnectionStatusUpdatedEventArgs("Device Not Connected To a Network")); } await wifiService.DisconnectFromWifiNetwork(new WifiNetwork() { SSID = e.SSID }); }); } else { Task.Run(async() => { await CompleteUpdate(); }); } } }
private void WifiService_CheckingConnectionStatusUpdated(object sender, Common.WiFi.CheckingConnectionStatusUpdatedEventArgs e) { if (e.IsConnected) { if (DeviceSetupService.SSIDIsEdisonDevice(e.SSID)) { switch (State) { case RegistrationState.ConnectingConnectingToDeviceFirstTime: State = RegistrationState.ConnectedToDevice; Task.Factory.StartNew(async() => { await GenerateDeviceInfo(new WifiNetwork() { SSID = e.SSID }); }, new CancellationTokenSource(TimeSpan.FromSeconds(20)).Token); break; case RegistrationState.ConnectingConnectingToDeviceSecondTime: State = RegistrationState.ConnectedToDevice; Task.Factory.StartNew(async() => { await OnboardDevice(); }, new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token); break; default: SetPairingStatusText($"State was set to {State}"); break; } } else { if (State == RegistrationState.DeviceInfoGenerated) { State = RegistrationState.ProvisioningWithCloud; Task.Factory.StartNew(async() => { await ProvisionWithCloud(); }, new CancellationTokenSource(TimeSpan.FromSeconds(20)).Token); } } } }
private async void WifiService_CheckingConnectionStatusUpdated(object sender, Common.WiFi.CheckingConnectionStatusUpdatedEventArgs e) { if (e.IsConnected && DeviceSetupService.SSIDIsEdisonDevice(e.SSID)) { var result = await onboardingRestService.ConnectToNetwork(new RequestNetworkInformationModel { NetworkInformation = new NetworkInformationModel { Ssid = ssid, Password = password, }, }); if (result.IsSuccess) { //change wifi back await wifiService.DisconnectFromWifiNetwork(deviceSetupService.CurrentDeviceHotspotNetwork); } PasswordSetCompleted?.Invoke(this, result.IsSuccess); } }