Print local time of the socket instead of UTC.
This commit is contained in:
parent
a4f74c24b1
commit
6368de10a3
|
@ -33,7 +33,7 @@ void ConsoleReader::run()
|
||||||
listSockets();
|
listSockets();
|
||||||
|
|
||||||
std::string command;
|
std::string command;
|
||||||
unsigned int number = 0;
|
activeSocket = 0;
|
||||||
bool cont = true;
|
bool cont = true;
|
||||||
|
|
||||||
while (cont) {
|
while (cont) {
|
||||||
|
@ -61,38 +61,38 @@ void ConsoleReader::run()
|
||||||
uint16_t countdown;
|
uint16_t countdown;
|
||||||
std::cout << "Countdown time in seconds: ";
|
std::cout << "Countdown time in seconds: ";
|
||||||
std::cin >> countdown;
|
std::cin >> countdown;
|
||||||
(*sockets) [number]->setCountDown(countdown);
|
(*sockets) [activeSocket]->setCountDown(countdown);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
(*sockets) [number]->toggleCountDown();
|
(*sockets) [activeSocket]->toggleCountDown();
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
(*sockets) [number]->tableData();
|
(*sockets) [activeSocket]->tableData();
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
(*sockets) [number]->discover();
|
(*sockets) [activeSocket]->discover();
|
||||||
break;
|
break;
|
||||||
case 'n': {
|
case 'n': {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::cout << "Please enter a new name: ";
|
std::cout << "Please enter a new name: ";
|
||||||
std::cin >> name;
|
std::cin >> name;
|
||||||
(*sockets) [number]->changeSocketName(QString::fromStdString(name));
|
(*sockets) [activeSocket]->changeSocketName(QString::fromStdString(name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
(*sockets) [number]->toggle();
|
(*sockets) [activeSocket]->toggle();
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (command == "off")
|
if (command == "off")
|
||||||
(*sockets) [number]->powerOff();
|
(*sockets) [activeSocket]->powerOff();
|
||||||
else if (command == "on")
|
else if (command == "on")
|
||||||
(*sockets) [number]->powerOn();
|
(*sockets) [activeSocket]->powerOn();
|
||||||
break;
|
break;
|
||||||
case 'P': {
|
case 'P': {
|
||||||
std::string password;
|
std::string password;
|
||||||
std::cout << "Please enter a new password: ";
|
std::cout << "Please enter a new password: ";
|
||||||
std::cin >> password;
|
std::cin >> password;
|
||||||
(*sockets) [number]->changeSocketPassword(QString::fromStdString(password));
|
(*sockets) [activeSocket]->changeSocketPassword(QString::fromStdString(password));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'q':
|
case 'q':
|
||||||
|
@ -100,8 +100,8 @@ void ConsoleReader::run()
|
||||||
emit(QCoreApplication::quit());
|
emit(QCoreApplication::quit());
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
std::cin >> number;
|
std::cin >> activeSocket;
|
||||||
--number; // count from 0
|
--activeSocket; // count from 0
|
||||||
listSockets();
|
listSockets();
|
||||||
break;
|
break;
|
||||||
case 't': {
|
case 't': {
|
||||||
|
@ -109,7 +109,7 @@ void ConsoleReader::run()
|
||||||
std::cout << "Please enter a new timezone (integer from -11 to 12): ";
|
std::cout << "Please enter a new timezone (integer from -11 to 12): ";
|
||||||
std::cin >> timezone;
|
std::cin >> timezone;
|
||||||
if (timezone >= -11 && timezone <= 12)
|
if (timezone >= -11 && timezone <= 12)
|
||||||
(*sockets) [number]->changeTimezone(timezone);
|
(*sockets) [activeSocket]->changeTimezone(timezone);
|
||||||
else
|
else
|
||||||
std::cout << "Invalid timezone";
|
std::cout << "Invalid timezone";
|
||||||
break;
|
break;
|
||||||
|
@ -129,6 +129,9 @@ void ConsoleReader::listSockets()
|
||||||
std::cout << "Countdown: " << (*i)->countdown << " " << ((*i)->countdownEnabled ? "(enabled)" : "(disabled)") << "\t\t Time: " << (*i)->socketDateTime.toString().toStdString() << std::endl;
|
std::cout << "Countdown: " << (*i)->countdown << " " << ((*i)->countdownEnabled ? "(enabled)" : "(disabled)") << "\t\t Time: " << (*i)->socketDateTime.toString().toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << "_____________________________________________________________________________\n" << std::endl;
|
std::cout << "_____________________________________________________________________________\n" << std::endl;
|
||||||
|
if (sockets->size() > 0) {
|
||||||
|
std::cout << "Active socket: " << (*sockets) [activeSocket]->socketName.toStdString() << std::endl;
|
||||||
|
}
|
||||||
std::cout << "a - add unpaired socket (WiFi needed)\n";
|
std::cout << "a - add unpaired socket (WiFi needed)\n";
|
||||||
std::cout << "A - add unpaired socket (no WiFi needed)\n";
|
std::cout << "A - add unpaired socket (no WiFi needed)\n";
|
||||||
std::cout << "c - set countdown\n";
|
std::cout << "c - set countdown\n";
|
||||||
|
@ -137,7 +140,7 @@ void ConsoleReader::listSockets()
|
||||||
std::cout << "D - resend discovery packet to the current socket\n";
|
std::cout << "D - resend discovery packet to the current socket\n";
|
||||||
std::cout << "n - change socket name (max 16 characters)\n";
|
std::cout << "n - change socket name (max 16 characters)\n";
|
||||||
std::cout << "p - toggle power state (there are also \"on\" and \"off\" commands)\n";
|
std::cout << "p - toggle power state (there are also \"on\" and \"off\" commands)\n";
|
||||||
std::cout << "P - change remote password (max 12 characters)\nq - quit\ns - pick another socket (default is 1)\nt - change timezone" << std::endl;
|
std::cout << "P - change remote password (max 12 characters)\nq - quit\ns - select another socket (default is 1)\nt - change timezone" << std::endl;
|
||||||
std::cout << "Enter command: " << std::endl;
|
std::cout << "Enter command: " << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Socket*> *sockets;
|
std::vector<Socket*> *sockets;
|
||||||
|
unsigned int activeSocket;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONSOLEREADER_H */
|
#endif /* CONSOLEREADER_H */
|
||||||
|
|
|
@ -272,6 +272,7 @@ bool Socket::parseReply(QByteArray reply)
|
||||||
timeZoneSet = reply.mid(index, 1);
|
timeZoneSet = reply.mid(index, 1);
|
||||||
++index;
|
++index;
|
||||||
timezone = hexToInt(reply.mid(index, 1));
|
timezone = hexToInt(reply.mid(index, 1));
|
||||||
|
socketDateTime = socketDateTime.addSecs(timezone *3600);
|
||||||
++index;
|
++index;
|
||||||
countdownEnabled = reply.mid(index, 2) == QByteArray::fromHex("01:00");
|
countdownEnabled = reply.mid(index, 2) == QByteArray::fromHex("01:00");
|
||||||
index += 2;
|
index += 2;
|
||||||
|
|
Loading…
Reference in New Issue