From 7c5d07b85461b84af17440aa9676d18a70edbe87 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 30 Oct 2022 20:44:01 +0100 Subject: working v3 --- client/Client.cpp | 7 +++---- client/HandleMessage.cpp | 18 ------------------ client/consts.h | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) (limited to 'client') diff --git a/client/Client.cpp b/client/Client.cpp index 2075fc2..cf4b3eb 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -54,10 +54,9 @@ void Client::timeFunction() { socket->write(msgToSend); } -void Client::missingRecords() -{ - QSqlQuery queryTimeData; - queryTimeData.exec("SELECT (unix_timestamp(now()) - unix_timestamp(`time`))/60 as delta FROM `tblMain` limit 1"); +void Client::missingRecords() { + QSqlQuery queryTimeData; + queryTimeData.exec("select unix_timestamp(now()) - unix_timestamp(time) as delta from WSdb.tblMain order by time desc limit 1"); queryTimeData.first(); unsigned int secondsSinceLastRecord = queryTimeData.value(0).toInt(); diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp index d719157..9599f86 100644 --- a/client/HandleMessage.cpp +++ b/client/HandleMessage.cpp @@ -3,23 +3,6 @@ HandleMessage::HandleMessage(QObject *parent) : QObject(parent) { } -// void HandleMessage::ParseToSQL(QString input) { -// QSqlQuery queryInsertData; -// QString output = "insert into WSdb.tblMain (temperature, humidity, pressure) values "; -// QStringList data; -// -// output.append("("); -// data=input.split(","); -// -// for (int i = 1; i < data.size(); i++) { -// bool valid; -// output.append(QString::number(data[i].toInt(&valid, 16))); -// if (i + 1 < data.size()) output.append(","); -// } -// -// output.append(")"); -// } - void HandleMessage::ParseToSQL(QString input) { QSqlQuery queryInsertData; QString output = "INSERT INTO `tblMain` (`temperature`, `humidity`, `pressure`) VALUES "; @@ -39,7 +22,6 @@ void HandleMessage::ParseToSQL(QString input) { if (i+1 < list.size()) output.append(","); } - printf("%s\n", output.toStdString().c_str()); queryInsertData.exec(output); } diff --git a/client/consts.h b/client/consts.h index a73fea7..1404dc2 100644 --- a/client/consts.h +++ b/client/consts.h @@ -3,5 +3,5 @@ #include "../shared/wifi.h" // delay between new record request in seconds -#define WS_CLIENT_STATION_POLL_INTERVAL 10 +#define WS_CLIENT_STATION_POLL_INTERVAL 1 -- cgit v1.2.3