From 6d5d7cf261f68c2e782e5b06a0638749996f0795 Mon Sep 17 00:00:00 2001 From: Ada Date: Fri, 22 Sep 2023 22:47:21 +0200 Subject: [PATCH] Update server to respond to status checking messages The simulator responds to unknown valid datagrams by returning them to the sender. --- simulation/VirtualLedBoard/udpserver.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/simulation/VirtualLedBoard/udpserver.cpp b/simulation/VirtualLedBoard/udpserver.cpp index 0acdf06..e1e9f14 100644 --- a/simulation/VirtualLedBoard/udpserver.cpp +++ b/simulation/VirtualLedBoard/udpserver.cpp @@ -2,6 +2,7 @@ #include "settings.h" #include #include +#include #include "mainwindow.h" #define UDP_IMAGE_PORT 4242 @@ -49,6 +50,7 @@ void UdpLedServer ::readPendingDatagrams() void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) { if (datagram.isValid() && datagram.data().length() == PACKET_LENGTH) { + qInfo("Received regular datagram."); uint8_t brightness = datagram.data().at(PACKET_INDEX_BRIGHTNESS); int currentIndex = PACKET_INDEX_PANEL0; @@ -70,5 +72,13 @@ void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) { qDebug() << "Received datagram:" << brightness; + } else if (datagram.isValid() && datagram.data().length() != PACKET_LENGTH) { + qDebug("Received status-check datagram."); + //socket = new QUdpSocket(this); + this->mUdpSocket->writeDatagram(datagram.data(), sizeof(datagram.data()), datagram.senderAddress(), datagram.senderPort()); + //this->mUdpSocket->writeDatagram(datagram); + qDebug("Returned datagram"); + } else { + qDebug("Received invalid datagram."); } }