/// <summary> /// Sample of how to send multiple numeric data /// </summary> public async Task SendNumericData(string topic, DateTimeOffset time, IEnumerable <float> measurement) { var sensorData = new[] { new SensorDataValue <float>(time, measurement) }; var payload = new SensorDataPackage <float>(sensorData).ToJson(); // Publish DeviceNodeInventory var roomMessage = new MqttApplicationMessageBuilder() .WithTopic($"{ClientId}/publish/DeviceProfile/{Node}/{topic}") .WithPayload(payload) .WithExactlyOnceQoS() .WithRetainFlag() .Build(); await mqttClient.PublishAsync(roomMessage); }
/// <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); }