示例#1
0
        /// <summary>
        /// Associate the current Pebble device by connecting to it and getting the current location
        /// </summary>
        /// <returns></returns>
        public async Task <bool> AssociatePebble(PebbleDevice _newDevice)
        {
            try
            {
                _newDevice.StoreAsAssociateDevice();

                int Token = await Connect(-1);

                if (IsConnected)
                {
                    Geolocator _geoLocater = new Geolocator();
                    _geoLocater.DesiredAccuracy = PositionAccuracy.High;
                    Geoposition _pos = await _geoLocater.GetGeopositionAsync();

                    Disconnect(Token);

                    return(true);
                }
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine("AssociatePebble: " + exp.Message);
                throw exp;
            }

            return(false);
        }