Ejemplo n.º 1
0
        private static async Task <bool> RegisterBridge()
        {
            if (IsBridgeInitialized())
            {
                try {
                    var result = await hueClient.RegisterAsync(GetAppName(), GetDeviceName());

                    SettingsController.SaveBridgeKey(result);
                    IsRegistered = true;
                } catch (Exception ex) {
                    // Send a message that the bridge's access is not granted
                }
            }

            return(IsRegistered);
        }
Ejemplo n.º 2
0
        public static async Task <bool> InitializeBridge()
        {
            // Check 1st if an secret key is avaible from app storage
            var key = SettingsController.RetrieveBridgeKey();

            hueClient = await GetBridge(key);

            if (!string.IsNullOrEmpty(key))
            {
                var check = await hueClient.CheckConnection();

                if (check)
                {
                    IsRegistered = true;
                    return(check);
                }
            }

            return(await RegisterBridge());
        }