|
|
@ -22,6 +22,7 @@ static const char *kMICROHARD_GROUP = "Microhard"; |
|
|
|
static const char *kLOCAL_IP = "LocalIP"; |
|
|
|
static const char *kLOCAL_IP = "LocalIP"; |
|
|
|
static const char *kREMOTE_IP = "RemoteIP"; |
|
|
|
static const char *kREMOTE_IP = "RemoteIP"; |
|
|
|
static const char *kNET_MASK = "NetMask"; |
|
|
|
static const char *kNET_MASK = "NetMask"; |
|
|
|
|
|
|
|
static const char *kCFG_USERNAME = "ConfigUserName"; |
|
|
|
static const char *kCFG_PASSWORD = "ConfigPassword"; |
|
|
|
static const char *kCFG_PASSWORD = "ConfigPassword"; |
|
|
|
static const char *kENC_KEY = "EncryptionKey"; |
|
|
|
static const char *kENC_KEY = "EncryptionKey"; |
|
|
|
|
|
|
|
|
|
|
@ -38,6 +39,7 @@ MicrohardManager::MicrohardManager(QGCApplication* app, QGCToolbox* toolbox) |
|
|
|
_localIPAddr = settings.value(kLOCAL_IP, QString("192.168.168.1")).toString(); |
|
|
|
_localIPAddr = settings.value(kLOCAL_IP, QString("192.168.168.1")).toString(); |
|
|
|
_remoteIPAddr = settings.value(kREMOTE_IP, QString("192.168.168.2")).toString(); |
|
|
|
_remoteIPAddr = settings.value(kREMOTE_IP, QString("192.168.168.2")).toString(); |
|
|
|
_netMask = settings.value(kNET_MASK, QString("255.255.255.0")).toString(); |
|
|
|
_netMask = settings.value(kNET_MASK, QString("255.255.255.0")).toString(); |
|
|
|
|
|
|
|
_configUserName = settings.value(kCFG_USERNAME, QString("admin")).toString(); |
|
|
|
_configPassword = settings.value(kCFG_PASSWORD, QString("admin")).toString(); |
|
|
|
_configPassword = settings.value(kCFG_PASSWORD, QString("admin")).toString(); |
|
|
|
_encryptionKey = settings.value(kENC_KEY, QString("1234567890")).toString(); |
|
|
|
_encryptionKey = settings.value(kENC_KEY, QString("1234567890")).toString(); |
|
|
|
settings.endGroup(); |
|
|
|
settings.endGroup(); |
|
|
@ -73,9 +75,9 @@ void |
|
|
|
MicrohardManager::_reset() |
|
|
|
MicrohardManager::_reset() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_close(); |
|
|
|
_close(); |
|
|
|
_isConnected = false; |
|
|
|
_connectedStatus = 0; |
|
|
|
emit connectedChanged(); |
|
|
|
emit connectedChanged(); |
|
|
|
_linkConnected = false; |
|
|
|
_linkConnectedStatus = 0; |
|
|
|
emit linkConnectedChanged(); |
|
|
|
emit linkConnectedChanged(); |
|
|
|
if(!_appSettings) { |
|
|
|
if(!_appSettings) { |
|
|
|
_appSettings = _toolbox->settingsManager()->appSettings(); |
|
|
|
_appSettings = _toolbox->settingsManager()->appSettings(); |
|
|
@ -114,10 +116,10 @@ MicrohardManager::setToolbox(QGCToolbox* toolbox) |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool |
|
|
|
bool |
|
|
|
MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString netMask_, QString cfgPassword_, QString encryptionKey_) |
|
|
|
MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString netMask_, QString cfgUserName_, QString cfgPassword_, QString encryptionKey_) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (_localIPAddr != localIP_ || _remoteIPAddr != remoteIP_ || _netMask != netMask_ || |
|
|
|
if (_localIPAddr != localIP_ || _remoteIPAddr != remoteIP_ || _netMask != netMask_ || |
|
|
|
_configPassword != cfgPassword_ || _encryptionKey != encryptionKey_) |
|
|
|
_configUserName != cfgUserName_ || _configPassword != cfgPassword_ || _encryptionKey != encryptionKey_) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (_mhSettingsLoc && _encryptionKey != encryptionKey_) { |
|
|
|
if (_mhSettingsLoc && _encryptionKey != encryptionKey_) { |
|
|
|
_mhSettingsLoc->setEncryptionKey(encryptionKey_); |
|
|
|
_mhSettingsLoc->setEncryptionKey(encryptionKey_); |
|
|
@ -126,6 +128,7 @@ MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString net |
|
|
|
_localIPAddr = localIP_; |
|
|
|
_localIPAddr = localIP_; |
|
|
|
_remoteIPAddr = remoteIP_; |
|
|
|
_remoteIPAddr = remoteIP_; |
|
|
|
_netMask = netMask_; |
|
|
|
_netMask = netMask_; |
|
|
|
|
|
|
|
_configUserName = cfgUserName_; |
|
|
|
_configPassword = cfgPassword_; |
|
|
|
_configPassword = cfgPassword_; |
|
|
|
_encryptionKey = encryptionKey_; |
|
|
|
_encryptionKey = encryptionKey_; |
|
|
|
|
|
|
|
|
|
|
@ -134,6 +137,7 @@ MicrohardManager::setIPSettings(QString localIP_, QString remoteIP_, QString net |
|
|
|
settings.setValue(kLOCAL_IP, localIP_); |
|
|
|
settings.setValue(kLOCAL_IP, localIP_); |
|
|
|
settings.setValue(kREMOTE_IP, remoteIP_); |
|
|
|
settings.setValue(kREMOTE_IP, remoteIP_); |
|
|
|
settings.setValue(kNET_MASK, netMask_); |
|
|
|
settings.setValue(kNET_MASK, netMask_); |
|
|
|
|
|
|
|
settings.setValue(kCFG_USERNAME, cfgUserName_); |
|
|
|
settings.setValue(kCFG_PASSWORD, cfgPassword_); |
|
|
|
settings.setValue(kCFG_PASSWORD, cfgPassword_); |
|
|
|
settings.setValue(kENC_KEY, encryptionKey_); |
|
|
|
settings.setValue(kENC_KEY, encryptionKey_); |
|
|
|
settings.endGroup(); |
|
|
|
settings.endGroup(); |
|
|
@ -172,20 +176,20 @@ MicrohardManager::_setEnabled() |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void |
|
|
|
void |
|
|
|
MicrohardManager::_connectedLoc() |
|
|
|
MicrohardManager::_connectedLoc(int status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qCDebug(MicrohardLog) << "GND Microhard Settings Connected"; |
|
|
|
qCDebug(MicrohardLog) << "GND Microhard Settings Connected"; |
|
|
|
_isConnected = true; |
|
|
|
_connectedStatus = status; |
|
|
|
_locTimer.start(LONG_TIMEOUT); |
|
|
|
_locTimer.start(LONG_TIMEOUT); |
|
|
|
emit connectedChanged(); |
|
|
|
emit connectedChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void |
|
|
|
void |
|
|
|
MicrohardManager::_connectedRem() |
|
|
|
MicrohardManager::_connectedRem(int status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qCDebug(MicrohardLog) << "AIR Microhard Settings Connected"; |
|
|
|
qCDebug(MicrohardLog) << "AIR Microhard Settings Connected"; |
|
|
|
_linkConnected = true; |
|
|
|
_linkConnectedStatus = status; |
|
|
|
_remTimer.start(LONG_TIMEOUT); |
|
|
|
_remTimer.start(LONG_TIMEOUT); |
|
|
|
emit linkConnectedChanged(); |
|
|
|
emit linkConnectedChanged(); |
|
|
|
} |
|
|
|
} |
|
|
@ -217,7 +221,7 @@ void |
|
|
|
MicrohardManager::_locTimeout() |
|
|
|
MicrohardManager::_locTimeout() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_locTimer.stop(); |
|
|
|
_locTimer.stop(); |
|
|
|
_isConnected = false; |
|
|
|
_connectedStatus = 0; |
|
|
|
if(_mhSettingsLoc) { |
|
|
|
if(_mhSettingsLoc) { |
|
|
|
_mhSettingsLoc->close(); |
|
|
|
_mhSettingsLoc->close(); |
|
|
|
_mhSettingsLoc->deleteLater(); |
|
|
|
_mhSettingsLoc->deleteLater(); |
|
|
@ -231,7 +235,7 @@ void |
|
|
|
MicrohardManager::_remTimeout() |
|
|
|
MicrohardManager::_remTimeout() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_remTimer.stop(); |
|
|
|
_remTimer.stop(); |
|
|
|
_linkConnected = false; |
|
|
|
_linkConnectedStatus = 0; |
|
|
|
if(_mhSettingsRem) { |
|
|
|
if(_mhSettingsRem) { |
|
|
|
_mhSettingsRem->close(); |
|
|
|
_mhSettingsRem->close(); |
|
|
|
_mhSettingsRem->deleteLater(); |
|
|
|
_mhSettingsRem->deleteLater(); |
|
|
@ -250,16 +254,16 @@ MicrohardManager::_checkMicrohard() |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!_isConnected) { |
|
|
|
if(_connectedStatus <= 0) { |
|
|
|
_mhSettingsLoc->start(); |
|
|
|
_mhSettingsLoc->start(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_mhSettingsLoc->getStatus(); |
|
|
|
_mhSettingsLoc->getStatus(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!_linkConnected) { |
|
|
|
if(_linkConnectedStatus <= 0) { |
|
|
|
_mhSettingsRem->start(); |
|
|
|
_mhSettingsRem->start(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_mhSettingsRem->getStatus(); |
|
|
|
_mhSettingsRem->getStatus(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_workTimer.start(_isConnected ? SHORT_TIMEOUT : LONG_TIMEOUT); |
|
|
|
_workTimer.start(_connectedStatus > 0 ? SHORT_TIMEOUT : LONG_TIMEOUT); |
|
|
|
} |
|
|
|
} |
|
|
|