public ConnectionController(INetworkSetting setting,
                             ITelloClient telloClient,
                             IWiFiManager wifiManager,
                             ILoggerFactory loggerFactory,
                             TelloClientHandler handler)
 {
     this.setting       = setting ?? throw new ArgumentNullException(nameof(setting));
     Client             = telloClient ?? throw new ArgumentNullException(nameof(telloClient));
     WiFi               = wifiManager ?? throw new ArgumentNullException(nameof(wifiManager));
     this.handler       = handler ?? throw new ArgumentNullException(nameof(handler));
     logger             = loggerFactory?.CreateLogger <ConnectionController>() ?? throw new ArgumentNullException(nameof(logger));
     handler.Connected += Handler_Connected;
     Connected          = false;
     tokenSource        = new CancellationTokenSource();
 }
        public WifiScanViewModel(INavigationService navigation) : base(navigation)
        {
            Devices          = new ObservableCollection <string>();
            wifiManager      = DependencyService.Get <IWiFiManager>();
            IsPairing        = false;
            Connect          = new Command(StartConnect);
            Title            = IoTCentral.Current.Device.Name;
            ProgressText     = "Searching for compatible devices...";
            PairingCompleted = false;
            PairingResult    = new Result();
            MessagingCenter.Subscribe <IWiFiManager, string>(this, "FOUND", async(manager, ssid) =>
            {
                Associate(ssid);
                await Pair();
            });
            MessagingCenter.Subscribe <IWiFiManager, string>(this, "REGISTERED", async(manager, msg) =>
            {
                var ssid = msg.Split(':')[0];
                if (ssid.Equals(deviceName, StringComparison.CurrentCultureIgnoreCase))
                {
                    ProgressText        = $"Device registered on the network with ip: {msg.Split(':')[1]}";
                    PairingResult.Text  = ((char)0x2713).ToString();
                    PairingResult.Color = Color.Green;
                }
                else
                {
                    ProgressText        = $"Failed to register device";
                    PairingResult.Text  = "X";
                    PairingResult.Color = Color.Red;
                }
                PairingCompleted = true;
                OnPropertyChanged("ProgressText");
                OnPropertyChanged("PairingCompleted");
                OnPropertyChanged("PairingResult");

                //await Navigation.NavigateTo(new DeviceViewModel(Navigation));
            });
            WiFIInstruction = ImageSource.FromResource("iotc_xamarin_ble.Resources.wifi_2.jpg");
            udpClient       = new UdpSocketClient();
            udpReceiver     = new UdpSocketReceiver();
            skipScan        = false;
            if (Device.RuntimePlatform == Device.iOS)
            {
                IsiOS = true;
                ((App)App.Current).ApplicationResumed += ResumeWifi;
            }
        }