aboutsummaryrefslogtreecommitdiff
path: root/client/HandleMessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/HandleMessage.cpp')
-rw-r--r--client/HandleMessage.cpp47
1 files changed, 14 insertions, 33 deletions
diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp
index dc25b21..a6b9ce4 100644
--- a/client/HandleMessage.cpp
+++ b/client/HandleMessage.cpp
@@ -1,43 +1,24 @@
#include "HandleMessage.h"
+HandleMessage::HandleMessage(QObject *parent) : QObject(parent) { }
-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;
-}
-
-QString HandleMessage::ParseMessage(const QString Msg , int totalRecords )
-{
- QString message= Msg.section('\n',2,(3+totalRecords));
+ output.append("(");
+ data=input.split(",");
- return message;
+ 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 WSdb.tblMain (temperature, humidity, pressure) values ";
- QStringList data;
- QStringList list = input.split("\n");
- for (int i = 0; i < list.size(); ++i) {
- output += "(";
- data=list[i].split(",");
- for (int j = 1; j < data.size(); ++j) {
- bool valid;
- output.append(QString::number(data[j].toInt(&valid, 16)));
- if (j <= data[j].size()) {
- output.append(",");
- }
-
- }
- output.append(")");
- if (i+1 < list.size()){
- output.append(",");
- }
- }
- printf("%s\n", output.toStdString().c_str());
- queryInsertData.exec(output);
+ queryInsertData.exec(output);
}