diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-16 14:56:46 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-16 14:56:46 +0200 |
| commit | bf525d35301dcf0c612598f4394e4357b8378746 (patch) | |
| tree | 25e104bd7c24ae22337e7e07385b67eca5053a3f /mock-jetting-controller/MockServer.cpp | |
| parent | e9d8a8b052150f42ea00da2c07e3f78a9b7d2061 (diff) | |
| download | QtXpl2-bf525d35301dcf0c612598f4394e4357b8378746.tar.gz QtXpl2-bf525d35301dcf0c612598f4394e4357b8378746.zip | |
fix: make ping exchange follow the protocol specification
Diffstat (limited to 'mock-jetting-controller/MockServer.cpp')
| -rw-r--r-- | mock-jetting-controller/MockServer.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mock-jetting-controller/MockServer.cpp b/mock-jetting-controller/MockServer.cpp index 08eb116..ac186cd 100644 --- a/mock-jetting-controller/MockServer.cpp +++ b/mock-jetting-controller/MockServer.cpp @@ -121,14 +121,11 @@ MockServer::onSocketMessageReady () void MockServer::tick () { - /* Send KA_PING on connected sockets, retry connection on disconnected. */ + /* Retry connection on disconnected sockets. Keepalive pings are originated + by the interface; the controller only replies to them. */ for (auto *port : { &m_command, &m_imaging, &m_status }) - { - if (port->socket.state () == QAbstractSocket::ConnectedState) - sendReply (port->socket, "KA_PING\n"); - else if (port->socket.state () == QAbstractSocket::UnconnectedState) - port->socket.connectToHost (m_host, port->number); - } + if (port->socket.state () == QAbstractSocket::UnconnectedState) + port->socket.connectToHost (m_host, port->number); } void @@ -241,11 +238,9 @@ MockServer::sendReply (QTcpSocket &socket, const QByteArray &data) void MockServer::handleKaPing (Port &port, const QByteArray ¶ms) { - QByteArray wire; - if (s_wireDebug) - wire = " << KA_PING," + params; - qDebug ("%s RX KA_PING ACK%s", qPrintable (logTag (&port.socket)), - wire.constData ()); + Q_UNUSED (params); + /* Reply to the interface's keepalive ping. */ + sendReply (port.socket, "KA_PING,1\n"); } void |
