Exemplo n.º 1
0
        public async Task <string> GetSensorData()
        {
            HumiditySensor      hum  = new HumiditySensor();
            IRTemperatureSensor temp = new IRTemperatureSensor();

            //hum.SensorValueChanged += SensorValueChanged;
            //temp.SensorValueChanged += SensorValueChanged;

            await hum.Initialize();

            await hum.EnableSensor();

            //await hum.EnableNotifications();


            await temp.Initialize();

            await temp.EnableSensor();

            //await temp.EnableNotifications();



            hum.SensorValueChanged  += SensorValueChanged;
            temp.SensorValueChanged += SensorValueChanged;

            await hum.EnableNotifications();

            await temp.EnableNotifications();


            return("done");
        }
Exemplo n.º 2
0
        private async void btnEnableNotifications_Click(object sender, RoutedEventArgs e)
        {
            await acc.EnableNotifications();

            await gyro.EnableNotifications();

            await hum.EnableNotifications();

            await ks.EnableNotifications();

            await mg.EnableNotifications();

            await ps.EnableNotifications();

            await tempSen.EnableNotifications();
        }
Exemplo n.º 3
0
        public async Task <string> InitializeSensor()
        {
            await hum.Initialize();

            await hum.EnableSensor();

            await temp.Initialize();

            await temp.EnableSensor();


            hum.SensorValueChanged  += SensorValueChanged;
            temp.SensorValueChanged += SensorValueChanged;

            await hum.EnableNotifications();

            await temp.EnableNotifications();

            return("done");
        }
Exemplo n.º 4
0
        private async void InitializeDevice()
        {
            Exception exc = null;

            try
            {
                tempSen = new IRTemperatureSensor();
                await tempSen.Initialize();

                await tempSen.EnableSensor();

                await tempSen.EnableNotifications();

                tempSen.SensorValueChanged += SensorValueChanged;

                humidSen = new HumiditySensor();
                await humidSen.Initialize();

                await humidSen.EnableSensor();

                await humidSen.EnableNotifications();

                humidSen.SensorValueChanged += SensorValueChanged;

                //await new MessageDialog("Device Connected").ShowAsync();
                //ReadDeviceData();
                ReadData.IsEnabled      = true;
                ConnectIoTHub.IsEnabled = true;
            }
            catch (Exception ex)
            {
                exc = ex;
                await new MessageDialog(exc.Message).ShowAsync();
            }

            if (exc != null)
            {
                await new MessageDialog(exc.Message).ShowAsync();
            }
        }