Add device serial api
This commit is contained in:
parent
a9c394b577
commit
8a327717db
@ -59,6 +59,11 @@ void SystemController::init()
|
|||||||
m_updateManagementAvailable = false;
|
m_updateManagementAvailable = false;
|
||||||
m_timeManagementAvailable = false;
|
m_timeManagementAvailable = false;
|
||||||
}
|
}
|
||||||
|
if (m_jsonRpcClient->ensureServerVersion("5.5")) {
|
||||||
|
m_jsonRpcClient->sendCommand("System.GetSystemInfo", this, "getSystemInfoResponse");
|
||||||
|
} else {
|
||||||
|
m_deviceSerialNumber.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemController::nameSpace() const
|
QString SystemController::nameSpace() const
|
||||||
@ -203,6 +208,11 @@ int SystemController::setAutomaticTime(bool automaticTime)
|
|||||||
return m_jsonRpcClient->sendCommand("System.SetTime", params, this, "setTimeResponse");
|
return m_jsonRpcClient->sendCommand("System.SetTime", params, this, "setTimeResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SystemController::deviceSerialNumber() const
|
||||||
|
{
|
||||||
|
return m_deviceSerialNumber;
|
||||||
|
}
|
||||||
|
|
||||||
void SystemController::getCapabilitiesResponse(int /*commandId*/, const QVariantMap &data)
|
void SystemController::getCapabilitiesResponse(int /*commandId*/, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
m_powerManagementAvailable = data.value("powerManagement").toBool();
|
m_powerManagementAvailable = data.value("powerManagement").toBool();
|
||||||
@ -318,6 +328,13 @@ void SystemController::shutdownResponse(int commandId, const QVariantMap ¶ms
|
|||||||
emit shutdownReply(commandId, success);
|
emit shutdownReply(commandId, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemController::getSystemInfoResponse(int commandId, const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
Q_UNUSED(commandId)
|
||||||
|
m_deviceSerialNumber = params.value("deviceSerialNumber").toString();
|
||||||
|
emit deviceSerialNumberChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void SystemController::notificationReceived(const QVariantMap &data)
|
void SystemController::notificationReceived(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
QString notification = data.value("notification").toString();
|
QString notification = data.value("notification").toString();
|
||||||
|
|||||||
@ -57,6 +57,8 @@ class SystemController : public JsonHandler
|
|||||||
Q_PROPERTY(bool automaticTimeAvailable READ automaticTimeAvailable NOTIFY automaticTimeAvailableChanged)
|
Q_PROPERTY(bool automaticTimeAvailable READ automaticTimeAvailable NOTIFY automaticTimeAvailableChanged)
|
||||||
Q_PROPERTY(bool automaticTime READ automaticTime WRITE setAutomaticTime NOTIFY automaticTimeChanged)
|
Q_PROPERTY(bool automaticTime READ automaticTime WRITE setAutomaticTime NOTIFY automaticTimeChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString deviceSerialNumber READ deviceSerialNumber NOTIFY deviceSerialNumberChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
||||||
|
|
||||||
@ -88,6 +90,8 @@ public:
|
|||||||
bool automaticTime() const;
|
bool automaticTime() const;
|
||||||
int setAutomaticTime(bool automaticTime);
|
int setAutomaticTime(bool automaticTime);
|
||||||
|
|
||||||
|
QString deviceSerialNumber() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void powerManagementAvailableChanged();
|
void powerManagementAvailableChanged();
|
||||||
void updateManagementAvailableChanged();
|
void updateManagementAvailableChanged();
|
||||||
@ -99,6 +103,7 @@ signals:
|
|||||||
void serverTimeZoneChanged();
|
void serverTimeZoneChanged();
|
||||||
void automaticTimeAvailableChanged();
|
void automaticTimeAvailableChanged();
|
||||||
void automaticTimeChanged();
|
void automaticTimeChanged();
|
||||||
|
void deviceSerialNumberChanged();
|
||||||
|
|
||||||
void restartReply(int id, bool success);
|
void restartReply(int id, bool success);
|
||||||
void rebootReply(int id, bool success);
|
void rebootReply(int id, bool success);
|
||||||
@ -116,6 +121,7 @@ private slots:
|
|||||||
void restartResponse(int commandId, const QVariantMap ¶ms);
|
void restartResponse(int commandId, const QVariantMap ¶ms);
|
||||||
void rebootResponse(int commandId, const QVariantMap ¶ms);
|
void rebootResponse(int commandId, const QVariantMap ¶ms);
|
||||||
void shutdownResponse(int commandId, const QVariantMap ¶ms);
|
void shutdownResponse(int commandId, const QVariantMap ¶ms);
|
||||||
|
void getSystemInfoResponse(int commandId, const QVariantMap ¶ms);
|
||||||
|
|
||||||
void notificationReceived(const QVariantMap &data);
|
void notificationReceived(const QVariantMap &data);
|
||||||
|
|
||||||
@ -140,6 +146,8 @@ private:
|
|||||||
QStringList m_timeZones;
|
QStringList m_timeZones;
|
||||||
bool m_automaticTimeAvailable = false;
|
bool m_automaticTimeAvailable = false;
|
||||||
bool m_automaticTime = false;
|
bool m_automaticTime = false;
|
||||||
|
|
||||||
|
QString m_deviceSerialNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYSTEMCONTROLLER_H
|
#endif // SYSTEMCONTROLLER_H
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import Nymea 1.0
|
|||||||
SwipeDelegate {
|
SwipeDelegate {
|
||||||
id: root
|
id: root
|
||||||
implicitWidth: 200
|
implicitWidth: 200
|
||||||
|
implicitHeight: Style.smallDelegateHeight
|
||||||
|
|
||||||
property string subText
|
property string subText
|
||||||
property bool progressive: true
|
property bool progressive: true
|
||||||
|
|||||||
@ -81,5 +81,13 @@ SettingsPageBase {
|
|||||||
progressive: false
|
progressive: false
|
||||||
prominentSubText: false
|
prominentSubText: false
|
||||||
}
|
}
|
||||||
|
NymeaSwipeDelegate {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: qsTr("Device serial number")
|
||||||
|
subText: engine.systemController.deviceSerialNumber
|
||||||
|
visible: engine.systemController.deviceSerialNumber.length > 0
|
||||||
|
progressive: false
|
||||||
|
prominentSubText: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user