Esempio n. 1
0
        public static void Go(IValueConf valueContainer)
        {
            Console.WriteLine("Anomali device\n");
            _deviceClient = DeviceClient.Create(IotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey(DeviceId, DeviceKey), TransportType.Mqtt);

            SendDeviceToCloudMessagesAsync(valueContainer);
            Console.ReadLine();
        }
Esempio n. 2
0
        private static async void SendDeviceToCloudMessagesAsync(IValueConf valueContainer)
        {
            while (true)
            {
                try{
                    var currentTemperature = valueContainer.Value + Rand.NextDouble() * valueContainer.Deviation;
                    var currentHumidity    = MinHumidity + Rand.NextDouble() * 20;

                    await SendTelemetryData(currentTemperature, currentHumidity);

                    valueContainer.Pingback(currentTemperature);

                    await Task.Delay(1000);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }