diff --git a/ScStwLibraries/headers/scstwclient.h b/ScStwLibraries/headers/scstwclient.h index f1ec27f..1955b70 100644 --- a/ScStwLibraries/headers/scstwclient.h +++ b/ScStwLibraries/headers/scstwclient.h @@ -40,7 +40,7 @@ public: * * \brief ScStwClient */ - explicit ScStwClient(); + explicit ScStwClient(QObject *parent = nullptr); enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED}; Q_ENUM(State); @@ -114,22 +114,6 @@ public slots: /*! updater functions */ - /*! - * \brief Function to set the timestamp of the base station to match the client - * \see getTimeOffset() - * \return true or false - */ - bool updateTime(); - - /*! - * \brief Function to update the firmware of the basestation to the version stored in the client - * \details will not do anything if the remote firmware is newer or the same as the clients one - * \see isFirmwareUpToDate() - * \see getFirmwareVersion() - * \return true: firmware was updated or is already up-to-date; false: there was an error during the update - */ - bool updateFirmware(); - /*! * \brief Function to check wether the firmware of the base station is up-to-date * \see getFirmwareVersion() @@ -138,14 +122,6 @@ public slots: */ bool isFirmwareUpToDate(); - // helper functions - - /*! - * \brief Function to pair all extensions that are currently connected via USB to the base station - * \return whether the pairing was successfull - */ - int pairConnectedUsbExtensions(); - /*! * \brief Function to write a setting on the base station * \param key the key to write to @@ -197,6 +173,12 @@ public slots: */ QString getFirmwareVersion(); + /*! + * \brief Function to get the current API version of the base station + * \return + */ + QString getApiVersion(); + /*! setter functions */ /*! diff --git a/ScStwLibraries/sources/scstwclient.cpp b/ScStwLibraries/sources/scstwclient.cpp index 8197ee5..068524f 100644 --- a/ScStwLibraries/sources/scstwclient.cpp +++ b/ScStwLibraries/sources/scstwclient.cpp @@ -2,7 +2,7 @@ ScStwClient * pGlobalScStwClient = nullptr; -ScStwClient::ScStwClient() : QObject(nullptr) +ScStwClient::ScStwClient(QObject * parent) : QObject(parent) { this->state = DISCONNECTED; this->nextConnectionId = 1; @@ -372,40 +372,6 @@ void ScStwClient::handleSignal(QVariantMap data) { // --- 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() { - if(this->state != CONNECTED) - return false; - - if(this->isFirmwareUpToDate()) - return true; - - QString file = ":/ScStwBasestation.sb64"; - QFile f(file); - if (!f.open(QFile::ReadOnly)){ - qDebug() << "read error " << f.error(); - return false; - } - QString fileContents = f.readAll(); - - QVariantMap ret = this->sendCommand(5000, fileContents, 15000); - - qDebug() << "updated firmware, status: " << ret["status"]; - - return ret["status"].toInt() == 200; -} - bool ScStwClient::isFirmwareUpToDate() { QString file = ":/ScStwBasestation.sb64"; QFile f(file); @@ -422,11 +388,6 @@ bool ScStwClient::isFirmwareUpToDate() { // --- helper functions --- // ------------------------ -int ScStwClient::pairConnectedUsbExtensions() { - QVariantMap ret = this->sendCommand(5002, "", 10000); - return ret["status"].toInt(); -} - ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStw::BaseStationSetting key, QString value) { QJsonArray requestData; requestData.append(key); @@ -476,6 +437,10 @@ QString ScStwClient::getFirmwareVersion() { return this->firmwareVersion; } +QString ScStwClient::getApiVersion() { + return this->apiVersion; +} + void ScStwClient::setExtensions(QVariantList extensions) { if(this->extensions != extensions){ this->extensions = extensions;