Esempio n. 1
0
        public async Task StartWorkAsync()
        {
            while (true)
            {
                double temp = await _weatherClient.GetTemperatureFromApiAsync(_serialNo);

                var mes = new Message
                {
                    SerialNo   = _serialNo,
                    DeviceName = _deviceName,
                    Timestamp  = DateTime.Now,
                    Value      = temp
                };

                var mesToSend = JsonConvert.SerializeObject(mes);

                await _mqttClient.PublishAsync(_devicePublishTopic, mesToSend);

                System.Threading.Thread.Sleep(_interval);
            }
        }