예제 #1
0
        private async void Watcher_Added(org.allseen.LSF.LampState.LampStateWatcher sender, Windows.Devices.AllJoyn.AllJoynServiceInfo args)
        {
            Debug.Write("Watcher_Added");

            string name = args.UniqueName;

            var session = await LampStateConsumer.JoinSessionAsync(args, sender);

            if (session.Status == AllJoynStatus.Ok)
            {
                AllJoynAboutDataView about = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, bus, args.SessionPort);

                if (about != null)
                {
                    FoundLight(session.Consumer, about);
                }
            }
            else
            {
                if (session.Status == AllJoynStatus.AuthenticationFailed)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.ConnectionRefused)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.Fail)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.InsufficientSecurity)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.OperationTimedOut)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.OtherEndClosed)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.SslConnectFailed)
                {
                    Debug.WriteLine("");
                }
                if (session.Status == AllJoynStatus.SslIdentityVerificationFailed)
                {
                    Debug.WriteLine("");
                }
            }
        }
예제 #2
0
        private async void Det_Added(org.allseen.LSF.LampDetails.LampDetailsWatcher sender, AllJoynServiceInfo args)
        {
            AllJoynAboutDataView about = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, bus, args.SessionPort);

            var appName = about.AppName;
            var devName = about.DeviceName;

            var vm = this.DataContext as ViewModels.MainPageViewModel;

            vm.AddBulb(devName, about.DeviceId);

            if (watcher == null)
            {
                watcher        = new org.allseen.LSF.LampState.LampStateWatcher(bus);
                watcher.Added += Watcher_Added;
                watcher.Start();
            }
        }
예제 #3
0
        public MainPage()
        {
            this.InitializeComponent();

            bus = new Windows.Devices.AllJoyn.AllJoynBusAttachment();
            bus.StateChanged         += Bus_StateChanged;
            bus.CredentialsRequested += Bus_CredentialsRequested;


            //     det = new org.allseen.LSF.LampDetails.LampDetailsWatcher(bus);
            //     det.Added += Det_Added;
            //     det.Start();

            watcher        = new org.allseen.LSF.LampState.LampStateWatcher(bus);
            watcher.Added += Watcher_Added;
            watcher.Start();

            TimerForPhilipsBuldUpdate          = new DispatcherTimer();
            TimerForPhilipsBuldUpdate.Interval = StartTime;
            TimerForPhilipsBuldUpdate.Tick    += TimerForPhilipsBuldUpdate_Tick;
            TimerForPhilipsBuldUpdate.Start();
        }