Esempio n. 1
0
        // TODO:
        // get device key from IoT Hub
        // get device name from User (from view)
        // save device key and device name into local storage
        // add owner name to json message
        // test location data of LocationManager
        // reverse geocode to get street address, etc
        // change visibility of textblock on view

        private async void InitializeSensors()
        {
            // Initialize the BMP180 Sensor
            try
            {
                _bmp180 = new Bmp180Sensor();
                await _bmp180.InitializeAsync();
            }
            catch (Exception ex)
            {
                LastUpdated = "Device Error! " + ex.Message;
            }

            if (_bmp180 == null)
            {
                return;
            }


            // get sensor data every 10 seconds
            _periodicTimer          = new DispatcherTimer();
            _periodicTimer.Interval = TimeSpan.FromSeconds(10);
            _periodicTimer.Tick    += _periodicTimer_Tick;
            _periodicTimer.Start();
        }
 private void CloseSensor()
 {
     try
     {
         _bmp180.Close();
     }
     catch (IOException e)
     {
         Log.Error("Test", "closeSensor  error: ", e);
     }
     _bmp180 = null;
 }
Esempio n. 3
0
        private async void InitializeSensors()
        {
            string calibrationData;

            // Initialize the BMP180 Sensor
            try
            {
                _bmp180 = new Bmp180Sensor();
                await _bmp180.InitializeAsync();

                calibrationData = _bmp180.CalibrationData.ToString();
            }
            catch (Exception ex)
            {
                calibrationData = "Device Error! " + ex.Message;
            }
        }
        /// <summary>
        /// Inicializacion del sensor
        /// </summary>
        private async void InitializeSensors()
        {
            string calibrationData;

            try
            {
                _bmp180 = new Bmp180Sensor();
                await _bmp180.InitializeAsync();

                calibrationData = _bmp180.CalibrationData.ToString();   //Retorna una cadena que representa al objeto actual.
                if (_periodicTimer == null)
                {
                    _periodicTimer = new Timer(this.TimerCallback, null, 0, readingInterval);
                }
            }
            catch (Exception ex)
            {
                calibrationData = "Error de dispositivo! " + ex.Message;
            }
        }
Esempio n. 5
0
        private async void InitializeSensors()
        {
            string calibrationData;

            // Initialize the BMP180 Sensor
            try
            {
                _bmp180 = new Bmp180Sensor();
                await _bmp180.InitializeAsync();

                calibrationData = _bmp180.CalibrationData.ToString();
            }
            catch (Exception ex)
            {
                calibrationData = "Device Error! " + ex.Message;
            }

            var task = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                calibrationDataTextBlock.Text = calibrationData;
            });
        }
 private void InitSensor()
 {
     _bmp180 = new Bmp180Sensor(I2CBus);
 }