Beispiel #1
0
        private async Task TryConnection()
        {
            Pebble.IsMusicControlEnabled = true;
            Pebble.IsLoggingEnabled = true;

            List<Pebble> pebbles = await Pebble.DetectPebbles();

            if (pebbles.Count >= 1)
            {
                _pebble = pebbles[0];
                await _pebble.ConnectAsync();

                if (_pebble != null && _pebble.IsConnected)
                {
                    _pebble.MusicControlReceived += new MusicControlReceivedHandler(this.MusicControlReceived);
                    _pebble.InstallProgress += new InstallProgressHandler(this.InstallProgressReceived);

                    PebbleName.Text = "Connected to Pebble " + _pebble.DisplayName;
                    PebbleVersion.Text = "Version " + _pebble.FirmwareVersion.Version + " - " + _pebble.FirmwareVersion.Timestamp.ToShortDateString();
                    RetryConnection.Visibility = Visibility.Collapsed;
                }
                else
                {
                    NotConnected();
                }
            }
        }
        public async Task SetPebbleAsync(Pebble pebble)
        {
            if (pebble == null) throw new ArgumentNullException("pebble");
            if (pebble.IsAlive == false)
            {
                await pebble.ConnectAsync();
            }

            Info.Pebble = Apps.Pebble = pebble;
            await Info.RefreshAsync();
            await Apps.RefreshAsync();
        }
        private async void OnToggleConnect( )
        {
            if (IsConnected)
            {
                _pebble.Disconnect();
                MessengerInstance.Send(new PebbleDisconnected(_pebble));
            }
            else
            {
                await _pebble.ConnectAsync();

                MessengerInstance.Send(new PebbleConnected(_pebble));
            }
            IsConnected = !IsConnected;
        }
        public async Task SetPebbleAsync(Pebble pebble)
        {
            if (pebble == null)
            {
                throw new ArgumentNullException("pebble");
            }
            if (pebble.IsAlive == false)
            {
                await pebble.ConnectAsync();
            }

            Info.Pebble = Apps.Pebble = pebble;
            await Info.RefreshAsync();

            await Apps.RefreshAsync();
        }
 public static void Startup(TestContext context)
 {
     _Pebble = PebbleNet45.DetectPebbles().SingleOrDefault();
     Assert.IsNotNull(_Pebble, "Could not find pebble");
     _Pebble.ConnectAsync().Wait();
 }