private async Task InitTargetDevice(DeviceInfo device)
        {
            Console.WriteLine("InitTargetDevice - started... ");
            Logger instance = Logger.Instance;

            object[] encryptionEnabled = new object[] { this.devicePairing.EncryptionEnabled };
            instance.LogMessageFormat("InitTargetDevice - EncryptionEnabled : {0}", encryptionEnabled);
            ISecondTvSecurityProvider noSecurityProvider = null;

            if (!this.devicePairing.EncryptionEnabled)
            {
                noSecurityProvider = new NoSecurityProvider();
            }
            else
            {
                noSecurityProvider = new AesSecurityProvider(this.devicePairing.SpcApi.GetKey(), this.devicePairing.SessionId);
            }
            Console.WriteLine("InitTargetDevice - Created Tv device.");

            ITargetDevice targetDevice = SmartTVRemoteControl.DeviceFactory.CreateTvDevice(device, this.notificationProvider, new DispatcherWrapper(Dispatcher.CurrentDispatcher), noSecurityProvider);

            Console.WriteLine("InitTargetDevice - Set current device.");
            this.SetCurrentDevice(targetDevice);
            try
            {
                Console.WriteLine("InitTargetDevice - Initialize Tv device.");
                AsyncContext.Run(() => targetDevice.InitializeAsync());
                //await targetDevice.InitializeAsync();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Console.WriteLine("[ERROR]Catch exception when initialize TV.");
                Logger logger = Logger.Instance;
                logger.LogMessageFormat("Exception message: {0}", new object[] { exception.Message });
                Logger instance1 = Logger.Instance;
                instance1.LogMessageFormat("Exception stacktrace: {0}", new object[] { exception.StackTrace });
            }
            finally
            {
                Console.WriteLine("InitTargetDevice is complete");
            }
        }
Exemplo n.º 2
0
        private async Task InitTargetDevice(DeviceInfo device)
        {
            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - started... ", new object[0]);
            Logger instance = Logger.Instance;

            object[] encryptionEnabled = new object[] { this.devicePairing.EncryptionEnabled };
            instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - EncryptionEnabled : {0}", encryptionEnabled);
            ISecondTvSecurityProvider noSecurityProvider = null;

            if (!this.devicePairing.EncryptionEnabled)
            {
                noSecurityProvider = new NoSecurityProvider();
            }
            else
            {
                noSecurityProvider = new AesSecurityProvider(this.devicePairing.SpcApi.GetKey(), this.devicePairing.SessionId);
            }
            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Created Tv device.", new object[0]);
            ITargetDevice targetDevice = SmartView2.DeviceFactory.CreateTvDevice(device, this.notificationProvider, this.dispatcher, noSecurityProvider);

            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Set current device.", new object[0]);
            this.SetCurrentDevice(targetDevice);
            try
            {
                Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Initialize Tv device.", new object[0]);
                await targetDevice.InitializeAsync();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Logger.Instance.LogMessageFormat("[SmartView2][DeviceController][ERROR]Catch exception when initialize TV.", new object[0]);
                Logger logger = Logger.Instance;
                logger.LogMessageFormat("[SmartView2][DeviceController]Exception message: {0}", new object[] { exception.Message });
                Logger instance1 = Logger.Instance;
                instance1.LogMessageFormat("[SmartView2][DeviceController]Exception stacktrace: {0}", new object[] { exception.StackTrace });
            }
        }