the extensions are also using the update protocol now

This commit is contained in:
dorian 2019-10-07 19:52:39 +02:00
parent 79b3c346fa
commit 8f295735da
3 changed files with 19 additions and 2 deletions

View file

@ -110,6 +110,8 @@ public slots:
Q_INVOKABLE bool refreshConnections(); Q_INVOKABLE bool refreshConnections();
void setConnections(QVariantList connections);
// functions for the qml adapter // functions for the qml adapter
QString getIP() const; QString getIP() const;
void setIP(const QString &ipAdress); void setIP(const QString &ipAdress);

View file

@ -50,13 +50,15 @@ bool BaseConn::init() {
this->setState("connected"); this->setState("connected");
// init remote session // init remote session
QJsonArray updateSubs = {"onRaceStateChanged", "onTimersChanged"}; QJsonArray updateSubs = {"onRaceStateChanged", "onTimersChanged", "onExtensionConnectionsChanged"};
QJsonObject sessionParams = {{"updateSubs", updateSubs}}; QJsonObject sessionParams = {{"updateSubs", updateSubs}};
if(this->sendCommand(1, sessionParams)["status"] != 200) { if(this->sendCommand(1, sessionParams)["status"] != 200) {
return false; return false;
} }
this->refreshConnections();
return true; return true;
} }
@ -385,3 +387,10 @@ QVariant BaseConn::getConnections() {
//QVariantList conns = {conn, conn1}; //QVariantList conns = {conn, conn1};
//return conns; //return conns;
} }
void BaseConn::setConnections(QVariantList connections) {
if(this->connections != connections){
this->connections = connections;
emit this->connectionsChanged();
}
}

View file

@ -36,7 +36,7 @@ ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
this->baseStationSyncTimer->setInterval(1000); this->baseStationSyncTimer->setInterval(1000);
this->baseStationSyncTimer->setSingleShot(true); this->baseStationSyncTimer->setSingleShot(true);
this->baseStationSyncTimer->connect(this->baseStationSyncTimer, &QTimer::timeout, this, &ClimbingRace::syncWithBaseStation); this->baseStationSyncTimer->connect(this->baseStationSyncTimer, &QTimer::timeout, this, &ClimbingRace::syncWithBaseStation);
this->baseStationSyncTimer->start(); //this->baseStationSyncTimer->start();
this->timerTextRefreshTimer = new QTimer(this); this->timerTextRefreshTimer = new QTimer(this);
this->timerTextRefreshTimer->setInterval(1); this->timerTextRefreshTimer->setInterval(1);
@ -284,6 +284,12 @@ void ClimbingRace::handleBaseStationUpdate(QVariant data) {
this->refreshRemoteTimers(data.toMap()["data"].toList()); this->refreshRemoteTimers(data.toMap()["data"].toList());
break; break;
} }
case 9002:
{
// the extension connections have changed
this->baseConn->setConnections(data.toMap()["data"].toList());
break;
}
} }
} }