/// <summary>
        /// Start measurements
        /// </summary>
        public async void Start()
        {
            //Clear previous measurements
            Measurements.Clear();
            Paused = false;

            _cancellationToken = new CancellationTokenSource();

            //Activate watch app
            if (_ConnectionToken == -1)
            {
                _ConnectionToken = await _pc.Connect(_ConnectionToken);

                if (_pc.IsConnected)
                {
                    await _pc.Launch(SportFace);
                }
            }

            if (_pc.Pebble != null)
            {
                _pc.Pebble.MessageReceived += ProtocolMessageReceived;
            }

            //Start thread

            /*var t = Task.Run(async () =>
             * {
             *  await ContinuousMeasurements();
             * });*/
        }
Exemple #2
0
        /// <summary>
        /// Delete selected items from phone and watch
        /// </summary>
        public async Task DeleteSelectedItems()
        {
            int _ConnectionToken = -1;

            try
            {
                //Collect all GUIDs of selected items
                List <Guid> GuidSelectedItems = new List <Guid>();

                var SelectedItems = WatchFaces.Where(x => x.Selected);

                foreach (var SelectedItem in SelectedItems)
                {
                    GuidSelectedItems.Add(SelectedItem.Model);
                }

                //Connect
                Connector.PebbleConnector _pc = Connector.PebbleConnector.GetInstance();

                _ConnectionToken = await _pc.Connect(_ConnectionToken);

                //Remove all selected items
                foreach (var GuidSelectdItem in GuidSelectedItems)
                {
                    var selecteditem = _pc.WatchItems.Where(x => x.ID == GuidSelectdItem);
                    await _pc.DeleteWatchItemAsync(selecteditem.First());
                }

                //Disconnect
                if (_pc.IsConnected)
                {
                    _pc.Disconnect(_ConnectionToken);
                }
            }
            catch (Exception)
            {
                Connector.PebbleConnector _pc = Connector.PebbleConnector.GetInstance();

                if (_pc.IsConnected)
                {
                    _pc.Disconnect(_ConnectionToken);
                }
            }

            NotifyPropertyChanged("ItemsSelected");
        }
        /// <summary>
        /// Connect to a pebble
        /// </summary>
        /// <returns></returns>
        private async Task Connect()
        {
            if (_ConnectionToken != -1)
            {
                throw new Exception("Notification connection still active.");
            }

            //Connect to the watch
            _pc = Connector.PebbleConnector.GetInstance();

            _ConnectionToken = await _pc.Connect(_ConnectionToken);

            if (!_pc.IsConnected)
            {
                throw new Exception("No connection with Pebble Time");
            }
        }
Exemple #4
0
        /// <summary>
        /// Connect to a pebble
        /// </summary>
        /// <returns></returns>
        public async Task Connect()
        {
            bool bNewConnection = false;

            //clear log
            Log.Clear();

            bNewConnection = !_pc.IsConnected;

            //Connect to the watch
            _ConnectionToken = await _pc.Connect(_ConnectionToken);

            if (!_pc.IsConnected)
            {
                Log.Add("No connection with Pebble Time.");
                Log.Add("Already connected or not paired?.");
                throw new Exception("No connection with Pebble Time");
            }

            if (bNewConnection)
            {
                Log.Add("Connected");
            }
        }