From e7c521bc10f1a15f3ce51f0a8550da9aec23c73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 21 Feb 2015 21:14:22 +0000 Subject: [PATCH] Print countdown. --- consolereader.cpp | 4 +++- server.cpp | 2 ++ socket.cpp | 5 +++-- socket.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/consolereader.cpp b/consolereader.cpp index 6941166..ddd8315 100644 --- a/consolereader.cpp +++ b/consolereader.cpp @@ -94,7 +94,9 @@ void ConsoleReader::listSockets() { std::cout << "_____________________________________________________________________________\n" << std::endl; std::cout << "IP Address: " << (*i)->ip.toString().toStdString() << "\t MAC Address: " << (*i)->mac.toHex().toStdString() << "\t Power: " << ( (*i)->powered ? "On" : "Off" ) << std::endl; - std::cout << "Socket Name: " << (*i)->socketName.toStdString() << "\t Remote Password: " << (*i)->remotePassword.toStdString() << "\t Timezone: " << (*i)->timeZone.toHex().toStdString() << std::endl; + std::cout << "Socket Name: " << (*i)->socketName.toStdString() << "\t Remote Password: " << (*i)->remotePassword.toStdString() << "\t Timezone: " << (*i)->timeZone.toHex().toStdString() + << std::endl; + std::cout << "Countdown: " << (*i)->countdown.toHex().toStdString() << std::endl; } std::cout << "_____________________________________________________________________________\n" << std::endl; std::cout << "d - update table data\nn - change socket name (max 16 characters)\np - toggle power state\nP - change remote password (max 12 characters)\n"; diff --git a/server.cpp b/server.cpp index fdb96c1..4633539 100644 --- a/server.cpp +++ b/server.cpp @@ -16,6 +16,7 @@ *************************************************************************/ #include +#include #include "consolereader.h" #include "server.h" @@ -91,6 +92,7 @@ void Server::readPendingDatagrams() } } + std::cout << "Packet not belonging to any socket: " << reply.toHex().toStdString() << std::endl; } } } diff --git a/socket.cpp b/socket.cpp index 817d14d..80ab9cd 100644 --- a/socket.cpp +++ b/socket.cpp @@ -39,11 +39,12 @@ Socket::Socket ( QHostAddress IPaddress, QByteArray reply ) commandID[SocketData] = commandID[TableData]; commandID[TimingData] = commandID[TableData]; commandID[WriteSocketData] = QByteArray::fromHex ( "74 6d" ); + QByteArray commandIDPower = QByteArray::fromHex ( "64 63" ); // 2 hex bytes are the total length of the message datagram[Subscribe] = commandID[Subscribe] + mac + twenties + rmac + twenties; - datagram[PowerOn] = QByteArray::fromHex ( "64 63" ) + mac + twenties + zeros + one; - datagram[PowerOff] = QByteArray::fromHex ( "64 63" ) + mac + twenties + zeros + zero; + datagram[PowerOn] = commandIDPower + mac + twenties + zeros + one; + datagram[PowerOff] = commandIDPower + mac + twenties + zeros + zero; datagram[TableData] = commandID[TableData] + mac + twenties + zeros + QByteArray::fromHex ( "01 00 00" ) + zeros; udpSocket = new QUdpSocket(); diff --git a/socket.h b/socket.h index 1275744..3adcd97 100644 --- a/socket.h +++ b/socket.h @@ -51,6 +51,7 @@ public: bool powered; QByteArray socketName, remotePassword; QByteArray timeZone; + QByteArray countdown; private: enum Datagram {Subscribe, PowerOff, PowerOn, TableData, SocketData, TimingData, WriteSocketData, MaxCommands}; @@ -78,7 +79,6 @@ private: QByteArray dhcpNode; QByteArray discoverable; QByteArray timeZoneSet; - QByteArray countdown; QByteArray socketTableNumber, socketTableVersion, timingTableNumber, timingTableVersion; // FIXME: not used yet const QByteArray twenties = QByteArray::fromHex ( "20 20 20 20 20 20" ); // mac address padding, 6 spaces