9#include <QtQml/QQmlEngine>
17 QQmlEngine::setObjectOwnership(
this, QQmlEngine::CppOwnership);
22 if (_vehicleReferenceCount != 0) {
23 qCWarning(LinkInterfaceLog) <<
"still have vehicle references:" << _vehicleReferenceCount;
32 qCWarning(LinkInterfaceLog) <<
"mavlinkChannelIsSet() == false";
35 return _mavlinkChannel;
40 return (LinkManager::invalidMavlinkChannel() != _mavlinkChannel);
46 auto mavlinkSettings = SettingsManager::instance()->mavlinkSettings();
47 const QByteArray signingKeyBytes = mavlinkSettings->
mavlink2SigningKey()->rawValue().toByteArray();
49 if (signingKeyBytes.isEmpty()) {
50 qCDebug(LinkInterfaceLog) <<
"Signing disabled on channel" << _mavlinkChannel;
52 qCDebug(LinkInterfaceLog) <<
"Signing enabled on channel" << _mavlinkChannel;
55 qCWarning(LinkInterfaceLog) <<
"Failed To enable Signing on channel" << _mavlinkChannel;
69 qCWarning(LinkInterfaceLog) <<
"already have" << _mavlinkChannel;
73 _mavlinkChannel = LinkManager::instance()->allocateMavlinkChannel();
76 qCWarning(LinkInterfaceLog) <<
"failed";
80 qCDebug(LinkInterfaceLog) <<
"_allocateMavlinkChannel" << _mavlinkChannel;
82 mavlink_set_proto_version(_mavlinkChannel, MAVLINK_VERSION);
90 qCDebug(LinkInterfaceLog) << _mavlinkChannel;
96 LinkManager::instance()->freeMavlinkChannel(_mavlinkChannel);
97 _mavlinkChannel = LinkManager::invalidMavlinkChannel();
102 const QByteArray data(bytes, length);
103 (void) QMetaObject::invokeMethod(
this,
"_writeBytes", Qt::AutoConnection, data);
108 if (_vehicleReferenceCount != 0) {
109 _vehicleReferenceCount--;
112 qCWarning(LinkInterfaceLog) <<
"called with no vehicle references";
118 if (_vehicleReferenceCount == 0) {
128 if (_signingSignatureFailure != failure) {
129 _signingSignatureFailure = failure;
130 if (_signingSignatureFailure) {
138 if (!_mavlinkV1TrafficReported) {
139 _mavlinkV1TrafficReported =
true;
142 const QString linkName = linkConfig ? linkConfig->name() : QStringLiteral(
"unknown");
143 qCWarning(LinkInterfaceLog) <<
"MAVLink v1 traffic detected on link" << linkName;
144 const QString message = tr(
"MAVLink v1 traffic detected on link '%1'. "
145 "%2 only supports MAVLink v2. "
146 "Please ensure your vehicle is configured to use MAVLink v2.")
147 .arg(linkName).arg(
qgcApp()->applicationName());
148 qgcApp()->showAppMessage(message);
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
#define QGC_LOGGING_CATEGORY(name, categoryStr)
The link interface defines the interface for all links used to communicate with the ground station ap...
uint8_t mavlinkChannel() const
virtual void _freeMavlinkChannel()
void reportMavlinkV1Traffic()
void _connectionRemoved()
bool mavlinkChannelIsSet() const
virtual bool _allocateMavlinkChannel()
virtual void disconnect()=0
bool initMavlinkSigning()
void removeVehicleReference()
virtual bool isSecureConnection() const
Returns true if the connection is secure (e.g. USB, wired ethernet)
void communicationError(const QString &title, const QString &error)
void setSigningSignatureFailure(bool failure)
void writeBytesThreadSafe(const char *bytes, int length)
SharedLinkConfigurationPtr linkConfiguration()
SharedLinkConfigurationPtr _config
Fact *mavlink2SigningKey READ mavlink2SigningKey CONSTANT Fact * mavlink2SigningKey()
bool insecureConnectionAccceptUnsignedCallback(const mavlink_status_t *status, uint32_t message_id)
bool initSigning(mavlink_channel_t channel, QByteArrayView key, mavlink_accept_unsigned_t callback)