Ajout timestamp dans payload MQTT
This commit is contained in:
2023-06-30 13:18:11 -04:00
parent b631eab073
commit 8b3cc9d2b6
5 changed files with 88 additions and 3 deletions
@@ -140,6 +140,12 @@ CMQTTMessage CCANDataLogger::GetMQTTMessage(CCANMessage *Msg, bool Format )
MsgTopic.append(Msg->mCANMsgName);
// MsgTopic.append("/");
#ifdef MQTT_TIMESTAMP_IN_PAYLOAD
QString TimeStamp = QDateTime::currentDateTime().toString(Qt::ISODate);
MsgPayload.append(QString("\"timestamp\":%1,").arg(TimeStamp));
#endif
//For each signal with new data, insert an entry in the JSon payload string
for(int signal = 0; signal < Msg->mSignalsList.size(); signal++)
{
+1 -1
View File
@@ -22,7 +22,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
ui(new Ui::CMainWindow)
{
ui->setupUi(this);
QMainWindow::statusBar()->showMessage("V1.01");
QMainWindow::statusBar()->showMessage("V1.02");
mGeneralStatusPage = new CGeneralStatusPage(this);
mMainWindowWidget = new QTabWidget(this);
+3 -2
View File
@@ -5,10 +5,11 @@
#define GENERAL_MESSAGES_MAX_LOG_LINES 5000 //The number of lines of general status log we keep in the general status window (avoids fucking up because you know.... RAM)
#define GENERAL_MESSAGES_SEND_TO_STDOUT //Comment this line to avoid printing log messages using qDebug.
#define MQTT_CLIENT_RECONNECT_TIMEOUT 5000 //Time in ms between reconnect attemps to MQTT broker when connection is lost
#define MQTT_CLIENT_MSG_QUEUE_FLUSH_TIMEOUT 500 //The delay in ms between the TX messages when flushing the msg queue after a server reconnection
#define MQTT_CLIENT_MSG_QUEUE_SIZE 1000 //The maximum number of messages to be queued. Older messages are lost when adding a new one in a full queue
#define MQTT_CLIENT_MSG_QUEUE_SIZE 500 //The maximum number of messages to be queued. Older messages are lost when adding a new one in a full queue
#define MQTT_TIMESTAMP_IN_PAYLOAD //Defining this adds the local timestamp to each MQTT payloads.
//#define USE_TOPIC_PREFIX