예제 #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);
        }
예제 #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());
        }