public BridgeDetectionPairingView() { _pairTimer.Interval = new TimeSpan(0, 0, 0, 2); _pairTimer.Tick += _pairTimer_Tick; _timeoutTimer.Interval = new TimeSpan(0, 0, 1, 0); _timeoutTimer.Tick += _timeoutTimer_Tick; Hue.OnDetectionComplete += Hue_OnDetectionComplete; Hue.OnBridgeDetectionFailed += Hue_OnBridgeDetectionFailed; Hue.OnIpScanComplete += Hue_OnIpScanComplete; Hue.OnIpScanProgressReport += Hue_OnIpScanProgressReport; if (BridgeStore.ListBridges.Count == 0) { Cursor_Tools.ShowWaitCursor(); CanAddManualIp = false; CanScan = false; CanDetectBridge = false; log.Info("Starting bridge detection."); Hue.DetectBridge(); } else { _defaultset = BridgeStore.ListBridges.Any(x => x.IsDefault); } }
public List <Bridge> LoadBridges(Dictionary <string, BridgeSaveSettings> savedbridges) { log.Info($"Loading saved bridges... {savedbridges.Count} bridge(s) found."); List <Bridge> bridges = new List <Bridge>(); foreach (KeyValuePair <string, BridgeSaveSettings> b in savedbridges) { IPAddress.TryParse(b.Value.ip, out IPAddress ip); if (ip == null) { log.Error($"Unable to parse IP ignoring bridge {b.Value.name}"); continue; } Bridge br = new Bridge() { IpAddress = ip }; BasicConfig bc = br.GetBridgeBasicConfig(); if (bc == null) { log.Warn("Bridge not responding. Does the IP address has changed ? Will try to find it..."); Hue.DetectBridge(); if (bc == null) { log.Error($"Cannot find this bridge {b.Value.name} ignoring it."); } } else { } } return(bridges); }
private void DetectBridge() { CanDetectBridge = false; CanScan = false; CanAddManualIp = false; OnPropertyChanged("CanDetectBridge"); Cursor_Tools.ShowWaitCursor(); Hue.DetectBridge(); }
public BridgeDetectionPairingView() { _pairTimer.Interval = new TimeSpan(0, 0, 0, 2); _pairTimer.Tick += _pairTimer_Tick; _timeoutTimer.Interval = new TimeSpan(0, 0, 1, 0); _timeoutTimer.Tick += _timeoutTimer_Tick; _listBridge = new ObservableCollection <Bridge>(); if (_listBridge.Count == 0) { CanAddManualIp = false; Cursor_Tools.ShowWaitCursor(); Hue.OnDetectionComplete += Hue_OnDetectionComplete; Hue.OnBridgeDetectionFailed += Hue_OnBridgeDetectionFailed; log.Info("Starting bridge detection."); Hue.DetectBridge(); _canscan = false; } else { AssociateApiKey(_listBridge); } }