#include #include #include #include #include #include #include #include #include "remoteControl.hpp" uint8_t RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right) { QUdpSocket udpSocket; QJsonObject commandObject = {{"sender", UDP_WHO_AM_I}, {"top", top}, {"left", left}, {"bottom", bottom}, {"right", right}}; QJsonDocument commandDocument(commandObject); QByteArray datagram = commandDocument.toJson(QJsonDocument::Compact); qint64 bytesSent = udpSocket.writeDatagram(datagram, QHostAddress("127.0.0.1"), UDP_PORT); if (bytesSent == -1) { qWarning("Failed to send the datagram: %s", qPrintable(udpSocket.errorString())); return 1; } return 0; }