Commit 44d8027d authored by Jacob Dahl's avatar Jacob Dahl

Added a transmitOnly flag to UDP config. When enabled, the socket receive...

Added a transmitOnly flag to UDP config. When enabled, the socket receive buffer is set to zero such that no data is ever received. Also updated the MavlinkSettings page such that new config settings respect the setting visibility.
parent af2309a9
......@@ -512,6 +512,7 @@ void LinkManager::_updateAutoConnectLinks(void)
UDPConfiguration* udpConfig = new UDPConfiguration(_mavlinkForwardingLinkName);
udpConfig->setDynamic(true);
udpConfig->setTransmitOnly(true);
QString hostName = _toolbox->settingsManager()->appSettings()->forwardMavlinkHostName()->rawValue().toString();
udpConfig->addHost(hostName);
......
......@@ -293,10 +293,18 @@ bool UDPLink::_hardwareConnect()
//-- Make sure we have a large enough IO buffers
#ifdef __mobile__
_socket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 64 * 1024);
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 128 * 1024);
if (_udpConfig->isTransmitOnly()) {
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 0);
} else {
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 128 * 1024);
}
#else
_socket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 256 * 1024);
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 512 * 1024);
if (_udpConfig->isTransmitOnly()) {
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 0);;
} else {
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 512 * 1024);;
}
#endif
_registerZeroconf(_udpConfig->localPort(), kZeroconfRegistration);
QObject::connect(_socket, &QUdpSocket::readyRead, this, &UDPLink::readBytes);
......@@ -369,7 +377,9 @@ void UDPLink::_deregisterZeroconf()
//--------------------------------------------------------------------------
//-- UDPConfiguration
UDPConfiguration::UDPConfiguration(const QString& name) : LinkConfiguration(name)
UDPConfiguration::UDPConfiguration(const QString& name)
: LinkConfiguration(name)
, _transmitOnly(false)
{
AutoConnectSettings* settings = qgcApp()->toolbox()->settingsManager()->autoConnectSettings();
_localPort = settings->udpListenPort()->rawValue().toInt();
......@@ -379,7 +389,9 @@ UDPConfiguration::UDPConfiguration(const QString& name) : LinkConfiguration(name
}
}
UDPConfiguration::UDPConfiguration(UDPConfiguration* source) : LinkConfiguration(source)
UDPConfiguration::UDPConfiguration(UDPConfiguration* source)
: LinkConfiguration(source)
, _transmitOnly(false)
{
_copyFrom(source);
}
......
......@@ -111,6 +111,14 @@ public:
*/
void setLocalPort (quint16 port);
/*!
* @brief Set the UDP port to be transmit only. Receive buffer is set to zero.
*
*/
void setTransmitOnly (bool state) { _transmitOnly = state; }
bool isTransmitOnly () { return _transmitOnly; }
/*!
* @brief QML Interface
*/
......@@ -142,6 +150,7 @@ private:
QList<UDPCLient*> _targetHosts;
QStringList _hostList; ///< Exposed to QML
quint16 _localPort;
bool _transmitOnly;
};
class UDPLink : public LinkInterface
......
......@@ -158,6 +158,7 @@ Rectangle {
id: mavlinkForwardingChecked
text: qsTr("Enable MAVLink forwarding")
fact: QGroundControl.settingsManager.appSettings.forwardMavlink
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.visible
}
Row {
......@@ -165,21 +166,24 @@ Rectangle {
QGCLabel {
width: _labelWidth
anchors.baseline: mavlinkForwardingHostNameField.baseline
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue &&
QGroundControl.settingsManager.appSettings.forwardMavlink.visible
text: qsTr("Host name:")
}
FactTextField {
id: mavlinkForwardingHostNameField
fact: QGroundControl.settingsManager.appSettings.forwardMavlinkHostName
width: _valueWidth
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue &&
QGroundControl.settingsManager.appSettings.forwardMavlink.visible
anchors.verticalCenter: parent.verticalCenter
}
}
QGCLabel {
text: qsTr("<i> Changing the host name requires restart of application. </i>")
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue
visible: QGroundControl.settingsManager.appSettings.forwardMavlink.rawValue &&
QGroundControl.settingsManager.appSettings.forwardMavlink.visible
}
}
}
......
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