Esempio n. 1
0
        private async void Timer_Tick(object sender, object e)
        {
            //Todo
            humidity    = HTU21DSensor.Humidity();
            temperature = HTU21DSensor.Temperature();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High,
                                      () =>
            {
                // UI can be accessed here
                UpdateScreen();
            });

            Debug.WriteLine("Humidity : " + humidity + " Temperature : " + temperature);
        }
Esempio n. 2
0
        private async void Timer_Tick(object sender, object e)
        {
            //Todo
            humidity    = HTU21DSensor.Humidity();
            temperature = HTU21DSensor.Temperature();

            //Todo
            var telemetryDataPoint = new
            {
                ObjectName        = deviceId,
                ObjectType        = "SensorTagEvent",
                Version           = "1.0",
                TargetAlarmDevice = deviceId,
                Temperature       = temperature
            };

            //Todo
            try
            {
                var messageString = JsonConvert.SerializeObject(telemetryDataPoint);
                var message       = new Message(Encoding.ASCII.GetBytes(messageString));
                await deviceClient.SendEventAsync(message);

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High,
                                          () =>
                {
                    // UI can be accessed here
                    UpdateScreen();
                });

                Debug.WriteLine("Humidity : " + humidity + " Temperature : " + temperature);
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("SendEventAsync error", NotifyType.ErrorMessage);
                return;
            }
        }