Exemplo n.º 1
0
        public async Task <IActionResult> Belly()
        {
            var data = new SensorDataValue("Belly");
            await _handleDataGeneration.GenerateAsync(data);

            return(ViewComponent("SensorData"));
        }
        /// <summary>
        /// Sample of how to send a single string data
        /// </summary>
        public async Task SendStatus(string topic, DateTimeOffset time, string status)
        {
            var sensorData = new SensorDataValue <string>[] { new SensorDataValue <string>(time, new string[] { status }) };
            var payload    = new SensorDataPackage <string>(sensorData).ToJson();

            // Publish DeviceNodeInventory
            var roomMessage = new MqttApplicationMessageBuilder()
                              .WithTopic($"{ClientId}/publish/DeviceProfile/{Node}/{topic}")
                              .WithPayload(payload)
                              .WithExactlyOnceQoS()
                              .WithRetainFlag()
                              .Build();

            await mqttClient.PublishAsync(roomMessage);
        }