Commit 8bc0c95c authored by Matej Frančeškin's avatar Matej Frančeškin

Microhard - removed unneeded settings

parent 4c989f93
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
......@@ -12,7 +12,6 @@
#include "QGCApplication.h"
#include "VideoManager.h"
QGC_LOGGING_CATEGORY(MicrohardLog, "MicrohardLog")
QGC_LOGGING_CATEGORY(MicrohardVerbose, "MicrohardVerbose")
......@@ -29,20 +28,16 @@ MicrohardHandler::~MicrohardHandler()
}
//-----------------------------------------------------------------------------
bool MicrohardHandler::close()
bool
MicrohardHandler::close()
{
bool res = (_tcpSocket || _tcpServer);
bool res = false;
if(_tcpSocket) {
qCDebug(MicrohardLog) << "Close Microhard TCP socket on port" << _tcpSocket->localPort();
_tcpSocket->close();
_tcpSocket->deleteLater();
_tcpSocket = nullptr;
}
if(_tcpServer) {
qCDebug(MicrohardLog) << "Close Microhard TCP server on port" << _tcpServer->serverPort();;
_tcpServer->close();
_tcpServer->deleteLater();
_tcpServer = nullptr;
res = true;
}
return res;
}
......@@ -52,53 +47,26 @@ bool
MicrohardHandler::_start(uint16_t port, QHostAddress addr)
{
close();
_serverMode = addr == QHostAddress::AnyIPv4;
if(_serverMode) {
if(!_tcpServer) {
qCDebug(MicrohardLog) << "Listen for Microhard TCP on port" << port;
_tcpServer = new QTcpServer(this);
QObject::connect(_tcpServer, &QTcpServer::newConnection, this, &MicrohardHandler::_newConnection);
_tcpServer->listen(QHostAddress::AnyIPv4, port);
}
} else {
_tcpSocket = new QTcpSocket();
QObject::connect(_tcpSocket, &QIODevice::readyRead, this, &MicrohardHandler::_readBytes);
qCDebug(MicrohardLog) << "Connecting to" << addr;
_tcpSocket->connectToHost(addr, port);
if (!_tcpSocket->waitForConnected(1000)) {
close();
return false;
}
emit connected();
}
return true;
}
//-----------------------------------------------------------------------------
void
MicrohardHandler::_newConnection()
{
qCDebug(MicrohardLog) << "New Microhard TCP Connection on port" << _tcpServer->serverPort();
if(_tcpSocket) {
_tcpSocket->close();
_tcpSocket->deleteLater();
}
_tcpSocket = _tcpServer->nextPendingConnection();
if(_tcpSocket) {
QObject::connect(_tcpSocket, &QIODevice::readyRead, this, &MicrohardHandler::_readBytes);
QObject::connect(_tcpSocket, &QAbstractSocket::disconnected, this, &MicrohardHandler::_socketDisconnected);
emit connected();
} else {
qCWarning(MicrohardLog) << "New Microhard TCP Connection provided no socket";
_tcpSocket = new QTcpSocket();
QObject::connect(_tcpSocket, &QIODevice::readyRead, this, &MicrohardHandler::_readBytes);
qCDebug(MicrohardLog) << "Connecting to" << addr;
_tcpSocket->connectToHost(addr, port);
if (!_tcpSocket->waitForConnected(1000)) {
close();
return false;
}
emit connected();
return true;
}
//-----------------------------------------------------------------------------
void
MicrohardHandler::_socketDisconnected()
{
qCDebug(MicrohardLog) << "Microhard TCP Connection Closed on port" << _tcpSocket->localPort();
if(_tcpSocket) {
qCDebug(MicrohardLog) << "Microhard TCP Connection Closed on port" << _tcpSocket->localPort();
_tcpSocket->close();
_tcpSocket->deleteLater();
_tcpSocket = nullptr;
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
......@@ -11,7 +11,7 @@
#include "QGCLoggingCategory.h"
#include <QTcpServer>
#include <QHostAddress>
#include <QTcpSocket>
#define MICROHARD_SETTINGS_PORT 23
......@@ -28,13 +28,11 @@ public:
~MicrohardHandler ();
virtual bool start () = 0;
virtual bool close ();
virtual bool isServerRunning () { return (_serverMode && _tcpServer); }
protected:
virtual bool _start (uint16_t port, QHostAddress addr = QHostAddress::AnyIPv4);
protected slots:
virtual void _newConnection ();
virtual void _socketDisconnected ();
virtual void _readBytes () = 0;
......@@ -43,7 +41,5 @@ signals:
void disconnected ();
protected:
bool _serverMode = true;
QTcpServer* _tcpServer = nullptr;
QTcpSocket* _tcpSocket = nullptr;
};
This diff is collapsed.
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
......@@ -29,24 +29,13 @@ public:
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
Q_PROPERTY(bool linkConnected READ linkConnected NOTIFY linkConnectedChanged)
Q_PROPERTY(bool needReboot READ needReboot NOTIFY needRebootChanged)
Q_PROPERTY(QString linkVidFormat READ linkVidFormat NOTIFY linkChanged)
Q_PROPERTY(int uplinkRSSI READ uplinkRSSI NOTIFY linkChanged)
Q_PROPERTY(int downlinkRSSI READ downlinkRSSI NOTIFY linkChanged)
Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY infoChanged)
Q_PROPERTY(QString fwVersion READ fwVersion NOTIFY infoChanged)
Q_PROPERTY(Fact* radioMode READ radioMode CONSTANT)
Q_PROPERTY(Fact* radioChannel READ radioChannel CONSTANT)
Q_PROPERTY(Fact* videoOutput READ videoOutput CONSTANT)
Q_PROPERTY(Fact* videoMode READ videoMode CONSTANT)
Q_PROPERTY(Fact* videoRate READ videoRate CONSTANT)
Q_PROPERTY(QString rtspURI READ rtspURI NOTIFY rtspURIChanged)
Q_PROPERTY(QString rtspAccount READ rtspAccount NOTIFY rtspAccountChanged)
Q_PROPERTY(QString rtspPassword READ rtspPassword NOTIFY rtspPasswordChanged)
Q_PROPERTY(QString localIPAddr READ localIPAddr NOTIFY localIPAddrChanged)
Q_PROPERTY(QString remoteIPAddr READ remoteIPAddr NOTIFY remoteIPAddrChanged)
Q_PROPERTY(QString netMask READ netMask NOTIFY netMaskChanged)
Q_PROPERTY(QString configPassword READ configPassword NOTIFY configPasswordChanged)
Q_INVOKABLE bool setRTSPSettings (QString uri, QString account, QString password);
Q_INVOKABLE bool setIPSettings (QString localIP, QString remoteIP, QString netMask);
explicit MicrohardManager (QGCApplication* app, QGCToolbox* toolbox);
......@@ -57,22 +46,12 @@ public:
bool connected () { return _isConnected; }
bool linkConnected () { return _linkConnected; }
bool needReboot () { return _needReboot; }
QString linkVidFormat () { return _linkVidFormat; }
int uplinkRSSI () { return _downlinkRSSI; }
int downlinkRSSI () { return _uplinkRSSI; }
QString serialNumber () { return _serialNumber; }
QString fwVersion () { return _fwVersion; }
Fact* radioMode () { return _radioMode; }
Fact* radioChannel () { return _radioChannel; }
Fact* videoOutput () { return _videoOutput; }
Fact* videoMode () { return _videoMode; }
Fact* videoRate () { return _videoRate; }
QString rtspURI () { return _rtspURI; }
QString rtspAccount () { return _rtspAccount; }
QString rtspPassword () { return _rtspPassword; }
QString localIPAddr () { return _localIPAddr; }
QString remoteIPAddr () { return _remoteIPAddr; }
QString netMask () { return _netMask; }
QString configPassword () { return _configPassword; }
signals:
void linkChanged ();
......@@ -81,13 +60,11 @@ signals:
void connectedChanged ();
void decodeIndexChanged ();
void rateIndexChanged ();
void rtspURIChanged ();
void rtspAccountChanged ();
void rtspPasswordChanged ();
void localIPAddrChanged ();
void remoteIPAddrChanged ();
void netMaskChanged ();
void needRebootChanged ();
void configPasswordChanged ();
private slots:
void _connected ();
......@@ -95,14 +72,10 @@ private slots:
void _checkMicrohard ();
void _updateSettings (QByteArray jSonData);
void _setEnabled ();
void _setVideoEnabled ();
void _radioSettingsChanged (QVariant);
void _videoSettingsChanged (QVariant);
private:
void _close ();
void _reset ();
void _restoreVideoSettings (Fact* setting);
FactMetaData *_createMetadata (const char *name, QStringList enums);
private:
......@@ -122,34 +95,16 @@ private:
bool _running = false;
bool _isConnected = false;
AppSettings* _appSettings = nullptr;
MicrohardSettings* _mhSettings = nullptr;
bool _enableVideo = true;
MicrohardSettings* _mhSettings = nullptr;
bool _enabled = true;
bool _linkConnected = false;
bool _needReboot = false;
QTimer _workTimer;
QString _linkVidFormat;
int _downlinkRSSI = 0;
int _uplinkRSSI = 0;
QStringList _decodeList;
int _decodeIndex = 0;
QStringList _rateList;
int _rateIndex = 0;
QString _serialNumber;
QString _fwVersion;
Fact* _radioMode = nullptr;
Fact* _radioChannel = nullptr;
Fact* _videoOutput = nullptr;
Fact* _videoMode = nullptr;
Fact* _videoRate = nullptr;
QStringList _radioModeList;
QStringList _videoOutputList;
QStringList _videoRateList;
QString _rtspURI;
QString _rtspAccount;
QString _rtspPassword;
QString _localIPAddr;
QString _remoteIPAddr;
QString _netMask;
QString _configPassword;
QTime _timeoutTimer;
};
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
......@@ -8,6 +8,7 @@
****************************************************************************/
#include "MicrohardSettings.h"
#include "MicrohardManager.h"
#include "SettingsManager.h"
#include "QGCApplication.h"
#include "VideoManager.h"
......@@ -19,11 +20,11 @@ MicrohardSettings::MicrohardSettings(QObject* parent)
}
//-----------------------------------------------------------------------------
bool MicrohardSettings::start()
bool
MicrohardSettings::start()
{
qCDebug(MicrohardLog) << "Start Microhard Settings";
return false;
// return _start(MICROHARD_SETTINGS_PORT, QHostAddress(qgcApp()->toolbox()->microhardManager()->remoteIPAddr()));
return _start(MICROHARD_SETTINGS_PORT, QHostAddress(qgcApp()->toolbox()->microhardManager()->remoteIPAddr()));
}
//-----------------------------------------------------------------------------
......@@ -33,52 +34,6 @@ MicrohardSettings::requestLinkStatus()
return _request("/v1/baseband.json");
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestDevInfo()
{
return _request("/v1/device.json");
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestFreqScan()
{
return _request("/v1/freqscan.json");
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestVideoSettings()
{
return false;
// return _request(kVideoURI);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestRadioSettings()
{
return false;
// return _request(kRadioURI);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestIPSettings()
{
return false;
// return _request(kIPAddrURI);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::requestRTSPURISettings()
{
return false;
// return _request(kRTSPURI);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::_request(const QString& request)
......@@ -109,38 +64,6 @@ MicrohardSettings::_post(const QString& post, const QString &postPayload)
return false;
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::setRadioSettings(const QString& mode, const QString& channel)
{
// static const char* kRadioPost = "{\"mode\":\"%1\",\"freq\":\"%2\"}";
// QString post = QString(kRadioPost).arg(mode).arg(channel);
return false;
// return _post(kRadioURI, post);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::setVideoSettings(const QString& output, const QString& mode, const QString& rate)
{
return false;
/*
static const char* kVideoPost = "{\"decode\":\"%1\",\"mode\":\"%2\",\"maxbitrate\":\"%3\"}";
QString post = QString(kVideoPost).arg(output).arg(mode).arg(rate);
return _post(kVideoURI, post);
*/
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::setRTSPSettings(const QString& uri, const QString& account, const QString& password)
{
return false;
// static const char* kRTSPPost = "{\"rtspURI\":\"%1\",\"account\":\"%2\",\"passwd\":\"%3\"}";
// QString post = QString(kRTSPPost).arg(uri).arg(account).arg(password);
// return _post(kRTSPURI, post);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings::setIPSettings(const QString& localIP, const QString& remoteIP, const QString& netMask)
......@@ -156,6 +79,8 @@ void
MicrohardSettings::_readBytes()
{
QByteArray bytesIn = _tcpSocket->read(_tcpSocket->bytesAvailable());
QString s_data = QString::fromStdString(bytesIn.toStdString());
//-- Go straight to Json payload
int idx = bytesIn.indexOf('{');
//-- We may receive more than one response within one TCP packet.
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
......@@ -15,18 +15,9 @@ class MicrohardSettings : public MicrohardHandler
{
Q_OBJECT
public:
explicit MicrohardSettings (QObject* parent = nullptr);
explicit MicrohardSettings (QObject* parent = nullptr);
bool start () override;
bool requestLinkStatus ();
bool requestDevInfo ();
bool requestFreqScan ();
bool requestVideoSettings ();
bool requestRadioSettings ();
bool requestIPSettings ();
bool requestRTSPURISettings ();
bool setRadioSettings (const QString& mode, const QString& channel);
bool setVideoSettings (const QString& output, const QString& mode, const QString& rate);
bool setRTSPSettings (const QString& uri, const QString& account, const QString& password);
bool setIPSettings (const QString& localIP, const QString& remoteIP, const QString& netMask);
signals:
......
This diff is collapsed.
......@@ -38,6 +38,9 @@
#if defined(QGC_GST_TAISYNC_ENABLED)
#include "TaisyncManager.h"
#endif
#if defined(QGC_GST_MICROHARD_ENABLED)
#include "MicrohardManager.h"
#endif
#if defined(QGC_CUSTOM_BUILD)
#include CUSTOMHEADER
......@@ -78,6 +81,9 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
#if defined(QGC_GST_TAISYNC_ENABLED)
_taisyncManager = new TaisyncManager (app, this);
#endif
#if defined(QGC_GST_MICROHARD_ENABLED)
_microhardManager = new MicrohardManager (app, this);
#endif
}
void QGCToolbox::setChildToolboxes(void)
......@@ -107,6 +113,9 @@ void QGCToolbox::setChildToolboxes(void)
#if defined(QGC_GST_TAISYNC_ENABLED)
_taisyncManager->setToolbox(this);
#endif
#if defined(QGC_GST_MICROHARD_ENABLED)
_microhardManager->setToolbox(this);
#endif
}
void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
......
......@@ -104,7 +104,7 @@ private:
TaisyncManager* _taisyncManager = nullptr;
#endif
#if defined(QGC_GST_MICROHARD_ENABLED)
MicrohardManager* _microhardManager = nullptr;
MicrohardManager* _microhardManager = nullptr;
#endif
friend class QGCApplication;
};
......
......@@ -228,11 +228,4 @@
"longDescription": "Enable Microhard Module Support",
"type": "bool",
"defaultValue": false
},
{
"name": "enableMicrohardVideo",
"shortDescription": "Enable Microhard Video Support",
"longDescription": "Enable Microhard Video Support",
"type": "bool",
"defaultValue": true
}]
......@@ -88,7 +88,6 @@ DECLARE_SETTINGSFACT(AppSettings, apmStartMavlinkStreams)
DECLARE_SETTINGSFACT(AppSettings, enableTaisync)
DECLARE_SETTINGSFACT(AppSettings, enableTaisyncVideo)
DECLARE_SETTINGSFACT(AppSettings, enableMicrohard)
DECLARE_SETTINGSFACT(AppSettings, enableMicrohardVideo)
DECLARE_SETTINGSFACT_NO_FUNC(AppSettings, indoorPalette)
{
......
......@@ -46,7 +46,6 @@ public:
DEFINE_SETTINGFACT(enableTaisync)
DEFINE_SETTINGFACT(enableTaisyncVideo)
DEFINE_SETTINGFACT(enableMicrohard)
DEFINE_SETTINGFACT(enableMicrohardVideo)
// Although this is a global setting it only affects ArduPilot vehicle since PX4 automatically starts the stream from the vehicle side
DEFINE_SETTINGFACT(apmStartMavlinkStreams)
......
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