diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-30 11:40:14 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-30 11:40:14 +0100 |
commit | e8b58762643f0a20454068e352738ecffc372c7e (patch) | |
tree | 360a2d312fe4bcf12c5aa513f0e47139c754621b | |
parent | e4f41ef8b56b76214d05bce34ffd5a8896da24c9 (diff) |
fix request send routine
-rw-r--r-- | client/Client.cpp | 16 | ||||
-rw-r--r-- | client/Client.h | 5 |
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 |