Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dorian Zedler 2020-05-18 10:50:16 +02:00
commit 3ae5977752
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 12 additions and 65 deletions

View file

@ -40,7 +40,7 @@ public:
* *
* \brief ScStwClient * \brief ScStwClient
*/ */
explicit ScStwClient(); explicit ScStwClient(QObject *parent = nullptr);
enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED}; enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED};
Q_ENUM(State); Q_ENUM(State);
@ -114,22 +114,6 @@ public slots:
/*! updater functions */ /*! 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 * \brief Function to check wether the firmware of the base station is up-to-date
* \see getFirmwareVersion() * \see getFirmwareVersion()
@ -138,14 +122,6 @@ public slots:
*/ */
bool isFirmwareUpToDate(); 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 * \brief Function to write a setting on the base station
* \param key the key to write to * \param key the key to write to
@ -197,6 +173,12 @@ public slots:
*/ */
QString getFirmwareVersion(); QString getFirmwareVersion();
/*!
* \brief Function to get the current API version of the base station
* \return
*/
QString getApiVersion();
/*! setter functions */ /*! setter functions */
/*! /*!

View file

@ -2,7 +2,7 @@
ScStwClient * pGlobalScStwClient = nullptr; ScStwClient * pGlobalScStwClient = nullptr;
ScStwClient::ScStwClient() : QObject(nullptr) ScStwClient::ScStwClient(QObject * parent) : QObject(parent)
{ {
this->state = DISCONNECTED; this->state = DISCONNECTED;
this->nextConnectionId = 1; this->nextConnectionId = 1;
@ -372,40 +372,6 @@ void ScStwClient::handleSignal(QVariantMap data) {
// --- updater functions --- // --- 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() { bool ScStwClient::isFirmwareUpToDate() {
QString file = ":/ScStwBasestation.sb64"; QString file = ":/ScStwBasestation.sb64";
QFile f(file); QFile f(file);
@ -422,11 +388,6 @@ bool ScStwClient::isFirmwareUpToDate() {
// --- helper functions --- // --- helper functions ---
// ------------------------ // ------------------------
int ScStwClient::pairConnectedUsbExtensions() {
QVariantMap ret = this->sendCommand(5002, "", 10000);
return ret["status"].toInt();
}
ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStw::BaseStationSetting key, QString value) { ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStw::BaseStationSetting key, QString value) {
QJsonArray requestData; QJsonArray requestData;
requestData.append(key); requestData.append(key);
@ -476,6 +437,10 @@ QString ScStwClient::getFirmwareVersion() {
return this->firmwareVersion; return this->firmwareVersion;
} }
QString ScStwClient::getApiVersion() {
return this->apiVersion;
}
void ScStwClient::setExtensions(QVariantList extensions) { void ScStwClient::setExtensions(QVariantList extensions) {
if(this->extensions != extensions){ if(this->extensions != extensions){
this->extensions = extensions; this->extensions = extensions;