2020-04-11 23:41:34 +02:00
|
|
|
#include "../headers/scstwclient.h"
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
ScStwClient * pGlobalScStwClient = nullptr;
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
ScStwClient::ScStwClient() : QObject(nullptr)
|
2020-04-05 14:11:52 +02:00
|
|
|
{
|
2020-04-06 17:51:20 +02:00
|
|
|
this->state = DISCONNECTED;
|
|
|
|
this->nextConnectionId = 1;
|
2020-04-18 14:25:48 +02:00
|
|
|
this->extensions = QVariantList({});
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
this->socket = new QTcpSocket(this);
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
this->timeoutTimer = new QTimer(this);
|
|
|
|
this->timeoutTimer->setSingleShot(true);
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
connect(this->timeoutTimer, &QTimer::timeout,
|
|
|
|
[=](){this->handleError(QAbstractSocket::ProxyConnectionTimeoutError);});
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
connect(this->socket, SIGNAL(error(QAbstractSocket::SocketError)),
|
2020-04-06 17:51:20 +02:00
|
|
|
this, SLOT(handleError(QAbstractSocket::SocketError)));
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
connect(this->socket, &QAbstractSocket::stateChanged,
|
|
|
|
this, &ScStwClient::handleSocketStateChange);
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 22:22:26 +02:00
|
|
|
connect(this->socket, &QAbstractSocket::readyRead,
|
2020-04-06 17:51:20 +02:00
|
|
|
this, &ScStwClient::handleReadyRead);
|
|
|
|
|
|
|
|
|
|
|
|
pGlobalScStwClient = this;
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::connectToHost() {
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
setState(CONNECTING);
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
//connect
|
|
|
|
this->socket->connectToHost(this->ip, this->port);
|
|
|
|
|
|
|
|
timeoutTimer->start(3000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::connectionTimeout() {
|
2020-04-06 17:51:20 +02:00
|
|
|
if(this->state != CONNECTING)
|
|
|
|
return;
|
|
|
|
|
2020-04-05 14:11:52 +02:00
|
|
|
this->socket->abort();
|
|
|
|
disconnect(this->timeoutTimer, SIGNAL(timeout()), this, SLOT(connectionTimeout()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScStwClient::init() {
|
2020-04-06 17:51:20 +02:00
|
|
|
if(this->state != CONNECTING)
|
|
|
|
return false;
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
this->setState(INITIALISING);
|
|
|
|
this->timeoutTimer->stop();
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
// init remote session
|
2020-04-06 17:51:20 +02:00
|
|
|
QJsonArray updateSubs = {ScStw::RaceStateChanged, ScStw::TimersChanged, ScStw::ExtensionsChanged, ScStw::NextStartActionChanged};
|
2020-04-05 14:11:52 +02:00
|
|
|
QJsonObject sessionParams = {{"updateSubs", updateSubs}, {"init", true}, {"usingTerminationKeys", true}};
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QVariantMap initResponse = this->sendCommand(1, sessionParams, 3000, false);
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
if(initResponse["status"] != 200) {
|
2020-04-06 17:51:20 +02:00
|
|
|
this->closeConnection();
|
2020-04-05 14:11:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->firmwareVersion = initResponse["data"].toMap()["version"].toString();
|
|
|
|
this->timeOffset = initResponse["data"].toMap()["time"].toDouble() - this->date->currentMSecsSinceEpoch();
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
qDebug() << "[INFO][BaseStation] Init done! firmware: version: " << this->firmwareVersion << " up-to-date: " << this->isFirmwareUpToDate() << " time offset: " << this->timeOffset;
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
this->setState(CONNECTED);
|
2020-04-05 14:11:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::deInit() {
|
2020-04-06 17:51:20 +02:00
|
|
|
if(this->state == DISCONNECTED)
|
|
|
|
return;
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
this->setExtensions(QVariantList({}));
|
2020-04-06 17:51:20 +02:00
|
|
|
this->setState(DISCONNECTED);
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::closeConnection()
|
|
|
|
{
|
2020-04-06 17:51:20 +02:00
|
|
|
if(this->getState() == DISCONNECTED)
|
|
|
|
return;
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
qDebug() << "closing connection";
|
|
|
|
switch (socket->state())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
socket->disconnectFromHost();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
socket->abort();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
socket->abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// --- socket communication handling ---
|
|
|
|
// -------------------------------------
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout) {
|
|
|
|
if(this->state != CONNECTED)
|
|
|
|
return {{"status", ScStw::NotConnectedError}, {"data", "not connected"}};
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 22:22:26 +02:00
|
|
|
return this->sendCommand(header, data, timeout, true);
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout, bool useTerminationKeys) {
|
|
|
|
if(this->state != CONNECTED && this->state != INITIALISING){
|
|
|
|
return {{"status", ScStw::NotConnectedError}, {"data", "not connected"}};
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// generate id and witing requests entry
|
|
|
|
int thisId = nextConnectionId;
|
|
|
|
//qDebug() << "sending command: " << header << " with data: " << data << " and id: " << thisId;
|
|
|
|
nextConnectionId ++;
|
|
|
|
|
|
|
|
QEventLoop *loop = new QEventLoop(this);
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
QJsonObject reply;
|
|
|
|
|
|
|
|
this->waitingRequests.append({thisId, loop, reply});
|
|
|
|
|
|
|
|
QJsonObject requestObj;
|
|
|
|
requestObj.insert("id", thisId);
|
|
|
|
requestObj.insert("header", header);
|
|
|
|
requestObj.insert("data", data);
|
|
|
|
|
|
|
|
QString jsonRequest = QJsonDocument(requestObj).toJson();
|
|
|
|
|
|
|
|
timer->setSingleShot(true);
|
|
|
|
// quit the loop when the timer times out
|
|
|
|
loop->connect(timer, SIGNAL(timeout()), loop, SLOT(quit()));
|
|
|
|
// start the timer before starting to connect
|
|
|
|
timer->start(timeout);
|
|
|
|
|
|
|
|
//write data
|
2020-04-06 22:22:26 +02:00
|
|
|
if(useTerminationKeys)
|
|
|
|
socket->write(ScStw::SOCKET_MESSAGE_START_KEY + jsonRequest.toUtf8() + ScStw::SOCKET_MESSAGE_END_KEY);
|
|
|
|
else
|
|
|
|
socket->write(jsonRequest.toUtf8());
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
//wait for an answer to finish (programm gets stuck in here)
|
|
|
|
loop->exec();
|
|
|
|
|
|
|
|
bool replyFound = false;
|
|
|
|
|
|
|
|
// find reply and delete the request from waiting list
|
|
|
|
for(int i = 0; i<this->waitingRequests.length(); i++){
|
|
|
|
if(this->waitingRequests[i].id == thisId){
|
|
|
|
// request was found
|
|
|
|
replyFound = true;
|
|
|
|
// delete event loop
|
|
|
|
if(this->waitingRequests[i].loop != nullptr) {
|
|
|
|
delete this->waitingRequests[i].loop;
|
|
|
|
}
|
|
|
|
// store reply
|
|
|
|
reply = this->waitingRequests[i].reply;
|
|
|
|
// remove reply from waiting list
|
|
|
|
this->waitingRequests.removeAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!replyFound) {
|
|
|
|
// some internal error occured
|
2020-04-06 22:22:26 +02:00
|
|
|
return {{"status", ScStw::Error}, {"data", ""}};
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(timer->remainingTime() == -1){
|
|
|
|
//the time has been triggered -> timeout
|
2020-04-06 17:51:20 +02:00
|
|
|
return {{"status", ScStw::TimeoutError}, {"data", ""}};
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
delete timer;
|
|
|
|
return {{"status", reply.value("header").toInt()}, {"data", reply.value("data").toVariant()}};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
void ScStwClient::handleSocketStateChange(QAbstractSocket::SocketState socketState) {
|
|
|
|
switch (socketState) {
|
|
|
|
case QAbstractSocket::UnconnectedState:
|
|
|
|
{
|
2020-04-06 22:53:58 +02:00
|
|
|
this->deInit();
|
2020-04-06 17:51:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QAbstractSocket::ConnectedState:
|
|
|
|
{
|
|
|
|
if(!this->init()) {
|
|
|
|
this->closeConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
//qDebug() << "+ --- UNKNOWN SOCKET STATE: " << socketState;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::handleError(QAbstractSocket::SocketError err)
|
|
|
|
{
|
|
|
|
if(err == QAbstractSocket::ProxyConnectionClosedError)
|
|
|
|
this->closeConnection();
|
|
|
|
|
|
|
|
switch (err) {
|
|
|
|
case QAbstractSocket::ProxyConnectionTimeoutError:
|
|
|
|
if(this->state == CONNECTING)
|
|
|
|
this->closeConnection();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
emit gotError(err);
|
|
|
|
qDebug() << "got socket error: " << err;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::handleReadyRead() {
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
//qDebug() << "ready to ready " << socket->bytesAvailable() << " bytes" ;
|
|
|
|
QString reply = socket->readAll();
|
|
|
|
|
|
|
|
//qWarning() << "socket read: " << reply;
|
|
|
|
|
|
|
|
processSocketMessage(reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::processSocketMessage(QString message) {
|
|
|
|
|
|
|
|
//qWarning() << "... processing message now ... : " << message;
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QString startKey = ScStw::SOCKET_MESSAGE_START_KEY;
|
|
|
|
QString endKey = ScStw::SOCKET_MESSAGE_END_KEY;
|
|
|
|
|
2020-04-05 14:11:52 +02:00
|
|
|
if(message == ""){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if((message.startsWith(startKey) && message.endsWith(endKey)) && (message.count(startKey) == 1 && message.count(endKey) == 1)){
|
|
|
|
// non-split message ( e.g.: <message>123456789</message>
|
|
|
|
}
|
|
|
|
else if(!message.contains(endKey) && (!this->readBuffer.isEmpty() || message.startsWith(startKey))){
|
|
|
|
// begin of a split message ( e.g.: <message>123 )
|
|
|
|
// or middle of a split message ( e.g.: 456 )
|
|
|
|
//qWarning() << "this is a begin or middle of split a message";
|
|
|
|
this->readBuffer += message;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(!message.contains(startKey) && message.endsWith(endKey)) {
|
|
|
|
// end of a split message ( e.g.: 789</message> )
|
|
|
|
|
|
|
|
if(!this->readBuffer.isEmpty()){
|
|
|
|
message = readBuffer + message;
|
|
|
|
readBuffer.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((message.count(startKey) > 1 || message.count(endKey) > 1) || (message.contains(endKey) && !message.endsWith(endKey) && message.contains(startKey) && !message.startsWith(startKey))) {
|
|
|
|
// multiple messages in one packet ( e.g.: <message>123456789</message><message>987654321</message> )
|
|
|
|
// or multiple message fragments in one message ( e.g.: 56789</message><message>987654321</message> or 56789</message><message>98765 )
|
|
|
|
//qDebug() << "detected multiple messages";
|
|
|
|
|
|
|
|
int startOfSecondMessage = message.lastIndexOf(startKey);
|
|
|
|
// process first part of message
|
|
|
|
QString firstMessage = message.left(startOfSecondMessage);
|
|
|
|
this->processSocketMessage(firstMessage);
|
|
|
|
// process second part of message
|
|
|
|
QString secondMessage = message.right(message.length() - startOfSecondMessage);
|
|
|
|
this->processSocketMessage(secondMessage);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// invalid message
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//qWarning() << "... done processing, message: " << message;
|
2020-04-06 17:51:20 +02:00
|
|
|
this->handleSocketMessage(message);
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
void ScStwClient::handleSocketMessage(QString reply) {
|
|
|
|
reply.replace(ScStw::SOCKET_MESSAGE_START_KEY, "");
|
|
|
|
reply.replace(ScStw::SOCKET_MESSAGE_END_KEY, "");
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 22:53:58 +02:00
|
|
|
//qDebug() << "got message: " << reply;
|
|
|
|
|
2020-04-05 14:11:52 +02:00
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
|
|
|
|
QJsonObject replyObj = jsonReply.object();
|
|
|
|
|
|
|
|
if(!replyObj.isEmpty()){
|
|
|
|
id = replyObj.value("id").toInt();
|
|
|
|
|
|
|
|
if(id == -1) {
|
|
|
|
// this message is an update!!
|
2020-04-06 17:51:20 +02:00
|
|
|
emit this->handleSignal(replyObj.toVariantMap());
|
2020-04-05 14:11:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this message is the reply to a command!
|
|
|
|
for(int i = 0; i < this->waitingRequests.length(); i++){
|
|
|
|
if(this->waitingRequests[i].id == id){
|
|
|
|
this->waitingRequests[i].reply = replyObj;
|
|
|
|
if(this->waitingRequests[i].loop != nullptr){
|
|
|
|
this->waitingRequests[i].loop->quit();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
emit gotUnexpectedMessage(reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::handleSignal(QVariantMap data) {
|
|
|
|
// get the signal type
|
2020-04-06 22:53:58 +02:00
|
|
|
if(ScStw::signalKeyFromInt(data["header"].toInt()) == ScStw::InvalidSignal)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ScStw::SignalKey signalKey = ScStw::signalKeyFromInt(data["header"].toInt());
|
|
|
|
|
|
|
|
//qDebug() << "got signal: " << signalKey << " with data: " << data["data"];
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
switch (signalKey) {
|
|
|
|
case ScStw::ExtensionsChanged:
|
|
|
|
{
|
|
|
|
// the extension connections have changed
|
|
|
|
// -> handle locally
|
2020-04-18 14:25:48 +02:00
|
|
|
this->setExtensions(data["data"].toList());
|
2020-04-06 17:51:20 +02:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// forward to external handlers
|
|
|
|
emit this->gotSignal(signalKey, data["data"]);
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------
|
|
|
|
// --- updater functions ---
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
bool ScStwClient::updateTime() {
|
|
|
|
if(abs(this->timeOffset) < 10000) {
|
|
|
|
// the time is already up-to-date
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariantMap ret = this->sendCommand(5001, this->date->currentSecsSinceEpoch());
|
|
|
|
qDebug() << ret;
|
|
|
|
|
|
|
|
return ret["status"].toInt() == 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScStwClient::updateFirmware() {
|
2020-04-06 17:51:20 +02:00
|
|
|
if(this->state != CONNECTED)
|
|
|
|
return false;
|
|
|
|
|
2020-04-07 16:32:35 +02:00
|
|
|
if(this->isFirmwareUpToDate())
|
|
|
|
return true;
|
|
|
|
|
2020-04-05 14:11:52 +02:00
|
|
|
QString file = ":/ScStwBasestation.sb64";
|
|
|
|
QFile f(file);
|
2020-04-07 16:32:35 +02:00
|
|
|
if (!f.open(QFile::ReadOnly)){
|
|
|
|
qDebug() << "read error " << f.error();
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-05 14:11:52 +02:00
|
|
|
QString fileContents = f.readAll();
|
|
|
|
|
2020-04-07 16:32:35 +02:00
|
|
|
QVariantMap ret = this->sendCommand(5000, fileContents, 15000);
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-07 16:32:35 +02:00
|
|
|
qDebug() << "updated firmware, status: " << ret["status"];
|
2020-04-05 14:11:52 +02:00
|
|
|
|
|
|
|
return ret["status"].toInt() == 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScStwClient::isFirmwareUpToDate() {
|
|
|
|
QString file = ":/ScStwBasestation.sb64";
|
|
|
|
QFile f(file);
|
|
|
|
if (!f.open(QFile::ReadOnly)) return false;
|
|
|
|
QString fileContents = f.readAll();
|
|
|
|
|
|
|
|
QString newFirmwareVersion = fileContents.split("<VER>")[1].split("</VER>")[0];
|
|
|
|
int newFirmwareVersionMajor = newFirmwareVersion.split(".")[0].toInt();
|
|
|
|
int newFirmwareVersionMinor = newFirmwareVersion.split(".")[1].toInt();
|
|
|
|
int newFirmwareVersionPatch = newFirmwareVersion.split(".")[2].toInt();
|
|
|
|
|
|
|
|
QString currentFirmwareVersion = this->firmwareVersion;
|
|
|
|
int currentFirmwareVersionMajor = currentFirmwareVersion.split(".")[0].toInt();
|
|
|
|
int currentFirmwareVersionMinor = currentFirmwareVersion.split(".")[1].toInt();
|
|
|
|
int currentFirmwareVersionPatch = currentFirmwareVersion.split(".")[2].toInt();
|
|
|
|
|
|
|
|
return newFirmwareVersionMajor < currentFirmwareVersionMajor || newFirmwareVersionMinor < currentFirmwareVersionMinor || newFirmwareVersionPatch <= currentFirmwareVersionPatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------
|
|
|
|
// --- helper functions ---
|
|
|
|
// ------------------------
|
|
|
|
|
2020-04-19 22:40:56 +02:00
|
|
|
int ScStwClient::pairConnectedUsbExtensions() {
|
2020-04-19 13:09:24 +02:00
|
|
|
QVariantMap ret = this->sendCommand(5002, "", 10000);
|
2020-04-19 22:40:56 +02:00
|
|
|
return ret["status"].toInt();
|
2020-04-19 13:09:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStw::BaseStationSetting key, QString value) {
|
2020-04-05 14:11:52 +02:00
|
|
|
QJsonArray requestData;
|
|
|
|
requestData.append(key);
|
|
|
|
requestData.append(value);
|
2020-04-19 13:09:24 +02:00
|
|
|
return ScStw::StatusCode(this->sendCommand(3000, requestData)["status"].toInt());
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QString ScStwClient::readRemoteSetting(ScStw::BaseStationSetting key) {
|
|
|
|
QVariantMap reply = this->sendCommand(3001, key);
|
|
|
|
if(reply["status"] != 200){
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
return reply["data"].toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwClient::setIP(QString newIp){
|
|
|
|
this->ip = newIp;
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ScStwClient::getIP()
|
|
|
|
{
|
|
|
|
return this->ip;
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
ScStwClient::State ScStwClient::getState()
|
2020-04-05 14:11:52 +02:00
|
|
|
{
|
|
|
|
return this->state;
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
void ScStwClient::setState(ScStwClient::State newState){
|
2020-04-05 14:11:52 +02:00
|
|
|
if(this->state != newState) {
|
|
|
|
qDebug() << "+--- ScStwClient state changed: " << newState;
|
|
|
|
this->state = newState;
|
|
|
|
emit stateChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
QVariantList ScStwClient::getExtensions() {
|
|
|
|
return this->extensions;
|
2020-04-06 17:51:20 +02:00
|
|
|
}
|
2020-04-05 14:11:52 +02:00
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
int ScStwClient::getTimeOffset() {
|
|
|
|
return this->timeOffset;
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:51:20 +02:00
|
|
|
QString ScStwClient::getFirmwareVersion() {
|
|
|
|
return this->firmwareVersion;
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
void ScStwClient::setExtensions(QVariantList extensions) {
|
|
|
|
if(this->extensions != extensions){
|
|
|
|
this->extensions = extensions;
|
|
|
|
emit this->gotSignal(ScStw::ExtensionsChanged, this->getExtensions());
|
|
|
|
emit this->extensionsChanged();
|
2020-04-05 14:11:52 +02:00
|
|
|
}
|
|
|
|
}
|