aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-10-30 20:33:41 +0100
committerlonkaars <loek@pipeframe.xyz>2022-10-30 20:33:41 +0100
commitea9463c3ba9335bc3d04dd04502ab9e67e8a718c (patch)
treede55f4b03eba50533f6dd220c31d50fa4239d94a /client
parentc0eeae6901572be2469ab61620c39cd2d3b2cb58 (diff)
finish merge
Diffstat (limited to 'client')
-rw-r--r--client/HandleMessage.cpp47
-rw-r--r--client/makefile14
2 files changed, 36 insertions, 25 deletions
diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp
index 02d7257..84f561b 100644
--- a/client/HandleMessage.cpp
+++ b/client/HandleMessage.cpp
@@ -1,4 +1,5 @@
#include "HandleMessage.h"
+#include "../shared/util.h"
HandleMessage::HandleMessage(QObject *parent) : QObject(parent) { }
@@ -20,31 +21,27 @@ HandleMessage::HandleMessage(QObject *parent) : QObject(parent) { }
// }
void HandleMessage::ParseToSQL(QString input) {
- QSqlQuery queryInsertData;
- QString output = "INSERT INTO `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(",");
- }
- }
- queryInsertData.exec(output);
+ QSqlQuery queryInsertData;
+ QString output = "INSERT INTO `tblMain` (`temperature`, `humidity`, `pressure`) VALUES ";
+ QStringList data;
+ QStringList list = input.split("\n");
+ for (int i = 0; i < list.size(); ++i) {
+ if (list[i].size() == 0) continue;
+ data=list[i].split(",");
+ bool valid;
+
+ output.append("(");
+ output.append(QString::number(ws_sensor_tmp_to_f(data[1].toInt(&valid, 16))));
+ output.append(",");
+ output.append(QString::number(ws_sensor_hum_to_f(data[2].toInt(&valid, 16))));
+ output.append(",");
+ output.append(QString::number(ws_sensor_atm_to_f(data[3].toInt(&valid, 16))));
+ output.append(")");
+
+ if (i+1 < list.size()) output.append(",");
+ }
+ printf("%s\n", output.toStdString().c_str());
+ queryInsertData.exec(output);
}
diff --git a/client/makefile b/client/makefile
new file mode 100644
index 0000000..a87857a
--- /dev/null
+++ b/client/makefile
@@ -0,0 +1,14 @@
+all: client
+
+ifeq ($(wildcard client.mk),)
+client.mk:
+ qmake client.pro -o client.mk
+endif
+
+include client.mk
+
+OBJECTS += $(patsubst %.c,%.o, $(wildcard ../shared/*.c))
+client: $(OBJECTS)
+
+../shared/%.o: ../shared/%.c
+ $(CC) -c $(CFLAGS) -w $< -o $@