diff options
author | NielsCoding <n.stunnebrink@student.avans.nl> | 2022-10-10 18:30:19 +0200 |
---|---|---|
committer | NielsCoding <n.stunnebrink@student.avans.nl> | 2022-10-10 18:30:19 +0200 |
commit | 2cdbf0173600183f1fb14fdd0e01f00e8b09f308 (patch) | |
tree | b1f4ace8a0fd769056377710b63006bef69a8c6a /client/esp/mytcpsocket.cpp | |
parent | 1000c8fd861b046a72bb3957dcc04cd6b28ceede (diff) |
esp code voor qt
Diffstat (limited to 'client/esp/mytcpsocket.cpp')
-rw-r--r-- | client/esp/mytcpsocket.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/client/esp/mytcpsocket.cpp b/client/esp/mytcpsocket.cpp new file mode 100644 index 0000000..92dd67a --- /dev/null +++ b/client/esp/mytcpsocket.cpp @@ -0,0 +1,44 @@ +#include <mytcpsocket.h> + +MyTcpSocket::MyTcpSocket(QObject *parent) : + QObject(parent) +{ +} + +void MyTcpSocket::doConnect() +{ + socket = new QTcpSocket(this); + + connect(socket, SIGNAL(connected()),this, SLOT(connected())); + connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected())); + // connect(socket, SIGNAL(bytesWritten(qint64)),this, SLOT(bytesWritten(qint64))); + connect(socket, SIGNAL(readyRead()),this, SLOT(readyRead())); + qDebug() << "connectig..."; + + socket->connectToHost("192.168.137.141",80); + + if(!socket->waitForConnected(5000)){ + qDebug()<<"Error: "<< socket->errorString(); + } +} + +void MyTcpSocket::connected(){ + qDebug() << "connected..."; + + socket->write("Weerdata: Temp:?\r\n\r\n\r\n\r\n"); + +} +void MyTcpSocket::disconnected(){ + qDebug() << "disconnected..."; + +} + +void MyTcpSocket::bytesWritten(qint64 bytes){ + qDebug() << bytes << "bytes written..."; + +} +void MyTcpSocket::readyRead(){ + qDebug() << "reading..."; + + qDebug() << socket->readAll(); +} |