Example #1
0
        private static async Task <string> SetUpIP()
        {
            string lipAddress = ipAddress;

            if (lipAddress == null)
            {
                Q42.HueApi.HttpBridgeLocator b = new Q42.HueApi.HttpBridgeLocator();
                var result = await b.LocateBridgesAsync(TimeSpan.FromSeconds(10));

                if (result != null)
                {
                    lipAddress = result.FirstOrDefault();
                }
            }

            if (lipAddress == null)
            {
                try
                {
                    Q42.HueApi.Interfaces.IBridgeLocator locator = new Q42.HueApi.WinRT.SSDPBridgeLocator();
                    var result = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(15));

                    if (result != null)
                    {
                        lipAddress = result.FirstOrDefault();
                    }
                }
                catch { }
            }

            return(lipAddress);
        }
Example #2
0
        //const string
        public static async Task <IEnumerable <HueBridgeDescription> > FindHueBridges()
        {
            IBridgeLocator       locator   = new Q42.HueApi.WinRT.SSDPBridgeLocator();
            IEnumerable <string> bridgeIPs = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(10));

            List <HueBridgeDescription> clients = new List <HueBridgeDescription>();

            foreach (var ip in bridgeIPs)
            {
                XmlDocument descriptionDoc = await XmlDocument.LoadFromUriAsync(new Uri($"http://{ip}/description.xml"));

                clients.Add(new HueBridgeDescription(descriptionDoc, ip));
            }
            return(clients);
        }
 //const string 
 public static async Task<IEnumerable<HueBridgeDescription>> FindHueBridges()
 {
     IBridgeLocator locator = new Q42.HueApi.WinRT.SSDPBridgeLocator();
     IEnumerable<string> bridgeIPs = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(10));
     List<HueBridgeDescription> clients = new List<HueBridgeDescription>();
     foreach (var ip in bridgeIPs)
     {
         XmlDocument descriptionDoc = await XmlDocument.LoadFromUriAsync(new Uri($"http://{ip}/description.xml"));
         clients.Add(new HueBridgeDescription(descriptionDoc, ip));
     }
     return clients;
 }