diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-30 20:44:01 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-30 20:44:01 +0100 |
commit | 7c5d07b85461b84af17440aa9676d18a70edbe87 (patch) | |
tree | 628782951f54bb5fe591adf9d32790114f17de72 | |
parent | f10fe5ad6bc561f05fcace7bb278e2a50c906208 (diff) |
working v3
-rw-r--r-- | client/Client.cpp | 7 | ||||
-rw-r--r-- | client/HandleMessage.cpp | 18 | ||||
-rw-r--r-- | client/consts.h | 2 |
3 files changed, 4 insertions, 23 deletions
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 |