diff --git a/NERODevelopment/src/models/mqtt_client.cpp b/NERODevelopment/src/models/mqtt_client.cpp index d829c4b..0467fd6 100644 --- a/NERODevelopment/src/models/mqtt_client.cpp +++ b/NERODevelopment/src/models/mqtt_client.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include MqttClient::MqttClient(QObject *parent) : QObject(parent) { @@ -89,6 +90,14 @@ void MqttClient::sendMessage(const QString topic, const float value) { serverdata::v2::ServerData serverData; serverData.setUnit(""); serverData.setValues({value}); + + auto now = std::chrono::system_clock::now(); + auto microseconds = std::chrono::duration_cast( + now.time_since_epoch()) + .count(); + QtProtobuf::uint64 timeUs = static_cast(microseconds); + + serverData.setTimeUs(timeUs); QByteArray data = serverData.serialize(&this->m_serializer); m_client->publish("NERO/" + topic, data); }