public async Task <IActionResult> LocateHue() { var t = await Task.WhenAll( new Task <string[]>[] { BridgeLocator.FindHueBridgeViaUpnp(device => { } , null), BridgeLocator.FindHueBridgeViaMeetHue() } ); HashSet <string> result = new HashSet <string>(); foreach (var x in t) { foreach (var s in x) { if (!result.Contains(s)) { result.Add(s); } } } return(Ok(result.ToArray())); }
public HueDiscovery(ColorService colorService) : base(colorService) { _bridgeLocatorHttp = new HttpBridgeLocator(); _bridgeLocatorMdns = new MdnsBridgeLocator(); _bridgeLocatorSsdp = new SsdpBridgeLocator(); _bridgeLocatorHttp.BridgeFound += DeviceFound; _bridgeLocatorMdns.BridgeFound += DeviceFound; _bridgeLocatorSsdp.BridgeFound += DeviceFound; _controlService = colorService.ControlService; }
/// <summary> /// Configures the bridge ip. /// </summary> private void ConfigureHueBridgeIp() { if (!string.IsNullOrEmpty(_bridgeIpAddress)) { return; } Logger.Debug("Hue Driver querying for bridge internal IP address"); var hueHub = new BridgeLocator(Logger).Execute(); if (hueHub == null) { Logger.Fatal("Hue Driver unable to get bridge address."); } else { _bridgeIpAddress = hueHub.InternalIpAddress; Logger.InfoFormat("Hue Driver bridge internal IP address is {0}", _bridgeIpAddress); } }