7#include <QtCore/QDeadlineTimer>
9#include <QtCore/QMutex>
10#include <QtCore/QMutexLocker>
11#include <QtCore/QStringList>
12#include <QtQmlIntegration/QtQmlIntegration>
35 Q_MOC_INCLUDE(
"QmlObjectListModel.h")
36 Q_MOC_INCLUDE(
"LogReplayLink.h")
38 Q_PROPERTY(
QmlObjectListModel *linkConfigurations READ _qmlLinkConfigurations CONSTANT)
69 QList<SharedLinkInterfacePtr>
links();
78 void setConnectionsSuspended(
const QString &reason) { _connectionsSuspended =
true; _connectionsSuspendedReason = reason; }
123 void _linkConnected();
124 void _linkDisconnected();
125 void _communicationError(
const QString &title,
const QString &error);
130 bool _connectionsSuspendedMsg()
const;
131 void _updateAutoConnectLinks();
133 void _addUDPAutoConnectLink();
134 void _addMAVLinkForwardingLink();
135 void _reconnectAutoConnectLinks();
137 void _retryDynamicUdpLink(
const QString& name,
const std::function<
void(
UDPConfiguration&)>& configure);
140 QTimer *_portListTimer =
nullptr;
144 bool _configUpdateSuspended =
false;
145 bool _configurationsLoaded =
false;
146 bool _connectionsSuspended =
false;
147 bool _mavlinkSupportForwardingEnabled =
false;
148 uint32_t _mavlinkChannelsUsedBitMask = 1;
149 QString _connectionsSuspendedReason;
152 QList<SharedLinkInterfacePtr> _rgLinks;
153 QList<SharedLinkConfigurationPtr> _rgLinkConfigs;
155 static constexpr const char *_defaultUDPLinkName =
"UDP Link (AutoConnect)";
156 static constexpr const char *_mavlinkForwardingLinkName =
"MAVLink Forwarding Link";
157 static constexpr const char *_mavlinkForwardingSupportLinkName =
"MAVLink Support Forwarding Link";
159 static constexpr int _autoconnectUpdateTimerMSecs = 1000;
160#ifndef QGC_NO_SERIAL_LINK
179 void _updateSerialPorts();
190 void _connectLinkAwaitingUsbPermission();
191 std::weak_ptr<LinkConfiguration> _configAwaitingUsbPermission;
192 QDeadlineTimer _usbPermissionDeadline;
193 std::unique_ptr<SerialAutoConnect> _serialAutoConnect;
194 QStringList _commPortList;
195 QStringList _commPortDisplayList;
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
std::shared_ptr< LinkInterface > SharedLinkInterfacePtr
Interface holding link specific settings.
The link interface defines the interface for all links used to communicate with the ground station ap...
void commPortStringsChanged()
Q_INVOKABLE void createConnectedLink(const LinkConfiguration *config)
This should only be used by Qml code.
Q_INVOKABLE bool serialPortHasFlowControl(const QString &portName) const
SharedLinkInterfacePtr sharedLinkInterfacePointerForLink(const LinkInterface *link)
QStringList serialPorts()
bool containsConfiguration(const QString &name) const
Q_INVOKABLE void endConfigurationEditing(LinkConfiguration *config, LinkConfiguration *editedConfig)
Q_INVOKABLE void cancelConfigurationEditing(LinkConfiguration *config) const
SharedLinkConfigurationPtr addConfiguration(LinkConfiguration *config)
QStringList linkTypeStrings() const
void isBluetoothAvailableChanged()
void loadLinkConfigurationList()
bool connectionsSuspended() const
static bool isLinkUSBDirect(const LinkInterface *link)
uint8_t allocateMavlinkChannel()
Q_INVOKABLE void createMavlinkForwardingSupportLink()
Q_INVOKABLE LinkConfiguration * createConfiguration(int type, const QString &name)
Create/Edit Link Configuration.
void startAutoConnectedLinks()
Q_INVOKABLE void endCreateConfiguration(LinkConfiguration *config)
void setConnectionsAllowed()
Sets the flag to allow new connections to be made.
Q_INVOKABLE void shutdown()
Called to signal app shutdown. Disconnects all links while turning off auto-connect.
LinkManager(QObject *parent=nullptr)
static LinkManager * instance()
void freeMavlinkChannel(uint8_t channel)
Q_INVOKABLE void removeConfiguration(LinkConfiguration *config)
friend class LinkManagerTest
QList< SharedLinkInterfacePtr > links()
static constexpr uint8_t invalidMavlinkChannel()
void setConnectionsSuspended(const QString &reason)
Q_INVOKABLE LogReplayLink * startLogReplay(const QString &logFile)
QStringList serialPortStrings()
Q_INVOKABLE void disconnectLink(LinkInterface *link)
static QStringList serialBaudRates()
SharedLinkInterfacePtr mavlinkForwardingSupportLink()
Returns pointer to the mavlink support forwarding link, or nullptr if it does not exist.
Q_INVOKABLE void disconnectLinkConfiguration(LinkConfiguration *config)
Stop a link and suppress auto-reconnect, working whether or not a live link currently exists.
Q_INVOKABLE LinkConfiguration * startConfigurationEditing(LinkConfiguration *config)
bool containsLink(const LinkInterface *link)
SharedLinkInterfacePtr mavlinkForwardingLink()
Returns pointer to the mavlink forwarding link, or nullptr if it does not exist.
static bool isBluetoothAvailable()
void saveLinkConfigurationList()
void mavlinkSupportForwardingEnabledChanged()
bool mavlinkSupportForwardingEnabled() const
MAVLink micro air vehicle protocol reference implementation.
Application-thread MAVLink serial discovery. LinkManager owns creation and live links.