Esempio n. 1
0
        private async Task SendPropertyChange(IEnumerable changedProperties, object userContext)
        {
            ValueSet properties = new ValueSet();

            foreach (var prop in changedProperties)
            {
                var pair  = (KeyValuePair <string, object>)prop;
                var value = pair.Value as JValue;
                if (value == null)
                {
                    Debug.WriteLine("Twin key " + pair.Key + " has unsupported type");
                    continue;
                }
                properties.Add(pair.Key, pair.Value.ToString());
            }
            await AppServiceBridge.SendMessageAsync(properties);
        }
Esempio n. 2
0
        private async void LogSensorDataAsync(ThreadPoolTimer timer)
        {
            var temperature = _station.ReadTemperature();
            var humidity    = _station.ReadHumidity();
            var pressure    = _station.ReadPressure();

            await _client.LogDataAsync(temperature, humidity, pressure);

            await AppServiceBridge.SendMessageAsync(new ValueSet
            {
                ["temperature"] = temperature,
                ["humidity"]    = humidity,
                ["pressure"]    = pressure
            });

            Debug.WriteLine("Logged data");
        }