From ddc103586c8e385c1b94e20f18b0dc03f747bf55 Mon Sep 17 00:00:00 2001 From: Viktor Verebelyi Date: Tue, 28 Mar 2023 18:15:32 +0100 Subject: [PATCH] Fix converting timestamp from MQTT payload --- connections/mqtt_bus.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connections/mqtt_bus.cpp b/connections/mqtt_bus.cpp index 951828e5..f8511faf 100644 --- a/connections/mqtt_bus.cpp +++ b/connections/mqtt_bus.cpp @@ -289,9 +289,10 @@ void MQTT_BUS::clientMessageReceived(const QMQTT::Message& message) if(frame_p) { uint32_t frameID = message.topic().split("/")[1].toInt(); - uint64_t timeStamp = message.payload()[0] + (message.payload()[1] << 8) + (message.payload()[2] << 16) + (message.payload()[3] << 24) - + ((uint64_t)message.payload()[4] << 32ull) + ((uint64_t)message.payload()[5] << 40ull) - + ((uint64_t)message.payload()[6] << 48ull) + ((uint64_t)message.payload()[7] << 56ull); + + QByteArray timeStampBytes = message.payload().left(8); + uint64_t timeStamp = qFromLittleEndian(timeStampBytes.data()); + int flags = message.payload()[8]; frame_p->setPayload(message.payload().right(message.payload().count() - 9)); frame_p->bus = 0;