Commit 703c675c authored by Matej Frančeškin's avatar Matej Frančeškin

Microhard - added air and ground IP addresses

parent abb57e6e
......@@ -20,6 +20,8 @@
static const char *kMICROHARD_GROUP = "Microhard";
static const char *kLOCAL_IP = "LocalIP";
static const char *kREMOTE_IP = "RemoteIP";
static const char *kGROUND_IP = "GroundIP";
static const char *kAIR_IP = "AirIP";
static const char *kNET_MASK = "NetMask";
static const char *kCFG_PASSWORD = "ConfigPassword";
static const char *kENC_KEY = "EncryptionKey";
......@@ -36,6 +38,8 @@ MicrohardManager::MicrohardManager(QGCApplication* app, QGCToolbox* toolbox)
settings.beginGroup(kMICROHARD_GROUP);
_localIPAddr = settings.value(kLOCAL_IP, QString("192.168.168.1")).toString();
_remoteIPAddr = settings.value(kREMOTE_IP, QString("192.168.168.2")).toString();
_groundIPAddr = settings.value(kGROUND_IP, QString("192.168.168.101")).toString();
_airIPAddr = settings.value(kAIR_IP, QString("192.168.168.213")).toString();
_netMask = settings.value(kNET_MASK, QString("255.255.255.0")).toString();
_configPassword = settings.value(kCFG_PASSWORD, QString("admin")).toString();
_encryptionKey = settings.value(kENC_KEY, QString("1234567890")).toString();
......@@ -113,10 +117,10 @@ MicrohardManager::setToolbox(QGCToolbox* toolbox)
//-----------------------------------------------------------------------------
bool
MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString netMask_, QString cfgPassword_, QString encryptionKey_)
MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString groundIP_, QString airIP_, QString netMask_, QString cfgPassword_, QString encryptionKey_)
{
if (_localIPAddr != localIP_ || _remoteIPAddr != remoteIP_ || _netMask != netMask_ ||
_configPassword != cfgPassword_ || _encryptionKey != encryptionKey_)
_configPassword != cfgPassword_ || _encryptionKey != encryptionKey_ || _groundIPAddr != groundIP_ || _airIPAddr != airIP_)
{
if (_mhSettingsLoc && _encryptionKey != encryptionKey_) {
_mhSettingsLoc->setEncryptionKey(encryptionKey_);
......@@ -124,6 +128,8 @@ MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString net
_localIPAddr = localIP_;
_remoteIPAddr = remoteIP_;
_groundIPAddr = groundIP_;
_airIPAddr = airIP_;
_netMask = netMask_;
_configPassword = cfgPassword_;
_encryptionKey = encryptionKey_;
......@@ -132,6 +138,8 @@ MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString net
settings.beginGroup(kMICROHARD_GROUP);
settings.setValue(kLOCAL_IP, localIP_);
settings.setValue(kREMOTE_IP, remoteIP_);
settings.setValue(kGROUND_IP, groundIP_);
settings.setValue(kAIR_IP, airIP_);
settings.setValue(kNET_MASK, netMask_);
settings.setValue(kCFG_PASSWORD, cfgPassword_);
settings.setValue(kENC_KEY, encryptionKey_);
......
......@@ -32,11 +32,13 @@ public:
Q_PROPERTY(int downlinkRSSI READ downlinkRSSI NOTIFY linkChanged)
Q_PROPERTY(QString localIPAddr READ localIPAddr NOTIFY localIPAddrChanged)
Q_PROPERTY(QString remoteIPAddr READ remoteIPAddr NOTIFY remoteIPAddrChanged)
Q_PROPERTY(QString groundIPAddr READ groundIPAddr NOTIFY groundIPAddrChanged)
Q_PROPERTY(QString airIPAddr READ airIPAddr NOTIFY airIPAddrChanged)
Q_PROPERTY(QString netMask READ netMask NOTIFY netMaskChanged)
Q_PROPERTY(QString configPassword READ configPassword NOTIFY configPasswordChanged)
Q_PROPERTY(QString encryptionKey READ encryptionKey NOTIFY encryptionKeyChanged)
Q_INVOKABLE bool setIPSettings (QString localIP, QString remoteIP, QString netMask, QString cfgPassword, QString encyrptionKey);
Q_INVOKABLE bool setIPSettings (QString localIP, QString remoteIP, QString groundIP, QString airIP, QString netMask, QString cfgPassword, QString encyrptionKey);
explicit MicrohardManager (QGCApplication* app, QGCToolbox* toolbox);
~MicrohardManager () override;
......@@ -49,6 +51,8 @@ public:
int downlinkRSSI () { return _uplinkRSSI; }
QString localIPAddr () { return _localIPAddr; }
QString remoteIPAddr () { return _remoteIPAddr; }
QString airIPAddr () { return _airIPAddr; }
QString groundIPAddr () { return _groundIPAddr; }
QString netMask () { return _netMask; }
QString configPassword () { return _configPassword; }
QString encryptionKey () { return _encryptionKey; }
......@@ -59,6 +63,8 @@ signals:
void connectedChanged ();
void localIPAddrChanged ();
void remoteIPAddrChanged ();
void airIPAddrChanged ();
void groundIPAddrChanged ();
void netMaskChanged ();
void configPasswordChanged ();
void encryptionKeyChanged ();
......@@ -92,6 +98,8 @@ private:
int _uplinkRSSI = 0;
QString _localIPAddr;
QString _remoteIPAddr;
QString _groundIPAddr;
QString _airIPAddr;
QString _netMask;
QString _configPassword;
QString _encryptionKey;
......
......@@ -54,7 +54,7 @@ MicrohardSettings::_readBytes()
{
QByteArray bytesIn = _tcpSocket->read(_tcpSocket->bytesAvailable());
qCDebug(MicrohardVerbose) << "Read bytes: " << bytesIn;
// qCDebug(MicrohardVerbose) << "Read bytes: " << bytesIn;
if (_loggedIn) {
int i1 = bytesIn.indexOf("RSSI (dBm)");
......
......@@ -185,7 +185,7 @@ QGCView {
anchors.horizontalCenter: parent.horizontalCenter
columns: 2
QGCLabel {
text: qsTr("Ground Unit IP Address:")
text: qsTr("Local IP Address:")
Layout.minimumWidth: _labelWidth
}
QGCTextField {
......@@ -196,7 +196,7 @@ QGCView {
Layout.minimumWidth: _valueWidth
}
QGCLabel {
text: qsTr("Air Unit IP Address:")
text: qsTr("Remote IP Address:")
}
QGCTextField {
id: remoteIP
......@@ -205,6 +205,27 @@ QGCView {
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.minimumWidth: _valueWidth
}
QGCLabel {
text: qsTr("Ground Unit IP Address:")
Layout.minimumWidth: _labelWidth
}
QGCTextField {
id: groundIP
text: QGroundControl.microhardManager.groundIPAddr
enabled: true
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.minimumWidth: _valueWidth
}
QGCLabel {
text: qsTr("Air Unit IP Address:")
}
QGCTextField {
id: airIP
text: QGroundControl.microhardManager.airIPAddr
enabled: true
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.minimumWidth: _valueWidth
}
QGCLabel {
text: qsTr("Network Mask:")
}
......@@ -249,12 +270,16 @@ QGCView {
function testEnabled() {
if(localIP.text === QGroundControl.microhardManager.localIPAddr &&
remoteIP.text === QGroundControl.microhardManager.remoteIPAddr &&
groundIP.text === QGroundControl.microhardManager.groundIPAddr &&
airIP.text === QGroundControl.microhardManager.airIPAddr &&
netMask.text === QGroundControl.microhardManager.netMask &&
configPassword.text === QGroundControl.microhardManager.configPassword &&
encryptionKey.text === QGroundControl.microhardManager.encryptionKey)
return false
if(!validateIPaddress(localIP.text)) return false
if(!validateIPaddress(remoteIP.text)) return false
if(!validateIPaddress(groundIP.text)) return false
if(!validateIPaddress(airIP.text)) return false
if(!validateIPaddress(netMask.text)) return false
return true
}
......@@ -262,7 +287,7 @@ QGCView {
text: qsTr("Apply")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
QGroundControl.microhardManager.setIPSettings(localIP.text, remoteIP.text, netMask.text, configPassword.text, encryptionKey.text)
QGroundControl.microhardManager.setIPSettings(localIP.text, remoteIP.text, groundIP.text, airIP.text, netMask.text, configPassword.text, encryptionKey.text)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment