aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/Client.cpp16
-rw-r--r--client/Client.h5
2 files changed, 11 insertions, 10 deletions
diff --git a/client/Client.cpp b/client/Client.cpp
index 10d288e..4d948fa 100644
--- a/client/Client.cpp
+++ b/client/Client.cpp
@@ -1,5 +1,8 @@
+#include <stdio.h>
+
#include "Client.h"
#include "consts.h"
+#include "../shared/util.h"
Client::Client(QObject *parent) : QObject(parent)
@@ -34,13 +37,12 @@ void Client::ClientEcho()
void Client::timeFunction()
{
- if(_missingRecords>1){
- totalRecords = _missingRecords;
- }
- else{
- totalRecords=1;
- }
- QByteArray msgToSend= (msg.toUtf8() + totalRecords + offsetRecords +'\n');
+ totalRecords = WS_MAX(1, _missingRecords);
+
+ char* msg = NULL;
+ asprintf(&msg, "last-records %x %x\n", totalRecords, offsetRecords);
+ QByteArray msgToSend = msg;
+ free(msg);
QTime time = QTime::currentTime();
qint16 currentSeconds = time.second();
diff --git a/client/Client.h b/client/Client.h
index f675a89..b90e5e9 100644
--- a/client/Client.h
+++ b/client/Client.h
@@ -35,9 +35,8 @@ private:
int tcpPortAddress = WS_SERVER_PORT; // port of communication via tcp
QString networkAddress = WS_ESP8266_WLAN_IP; // network address for commincation via tcp
- QString msg = "last-records "; // part of mesage to send to wheather staion
- char totalRecords = '1'; // total records to ask wheather station
- char offsetRecords = '0'; // offset from reqeusting records
+ uint8_t totalRecords = 1; // total records to ask wheather station
+ uint8_t offsetRecords = 0; // offset from reqeusting records
};
#endif // CLIENT_H