/// <summary>
        /// The task for continuously monitoring the position; every 5 seconds
        /// </summary>
        /// <returns></returns>
        private async Task ContinuousMeasurements()
        {
            int i = 0;

            IsRunning = true;

            while (!CancellationToken.IsCancellationRequested)
            {
                //Write debug line
                //System.Diagnostics.Debug.WriteLine(String.Format("{0} - {1} - {2} - {3} - {4}", i, _newMeasurement.Position.Latitude, _newMeasurement.Position.Longitude, _newMeasurement.Position.Altitude, DateTime.Now));

                //Wait for 5 seconds
                System.Threading.Tasks.Task.Delay(1000).Wait();

                i++;
            }

            if (_ConnectionToken != -1)
            {
                _pc.Disconnect(_ConnectionToken);
                _ConnectionToken = -1;
            }

            IsRunning = false;
        }
示例#2
0
        /// <summary>
        /// Disconnect from the Pebble
        /// </summary>
        private void Disconnect()
        {
            //Disconnect
            _pc.Disconnect(_ConnectionToken);

            _ConnectionToken = -1;

            if (!_pc.IsConnected)
            {
                Log.Add("Disconnected");
            }
        }
示例#3
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>
        /// Disconnect from the Pebble
        /// </summary>
        private void Disconnect()
        {
            _pc.Disconnect(_ConnectionToken);

            _ConnectionToken = -1;
        }