Skip to content

Commit

Permalink
Comms: Fixup LinkManager
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Sep 21, 2024
1 parent cea5ee0 commit 008ae6e
Show file tree
Hide file tree
Showing 20 changed files with 562 additions and 558 deletions.
8 changes: 4 additions & 4 deletions src/Comms/BluetoothLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ BluetoothConfiguration::BluetoothConfiguration(const QString& name)

}

BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration* source)
BluetoothConfiguration::BluetoothConfiguration(const BluetoothConfiguration* source)
: LinkConfiguration(source)
, _deviceDiscover(nullptr)
, _device(source->device())
Expand All @@ -222,10 +222,10 @@ QString BluetoothConfiguration::settingsTitle()
}
}

void BluetoothConfiguration::copyFrom(LinkConfiguration *source)
void BluetoothConfiguration::copyFrom(const LinkConfiguration *source)
{
LinkConfiguration::copyFrom(source);
auto* usource = qobject_cast<BluetoothConfiguration*>(source);
const BluetoothConfiguration* const usource = qobject_cast<const BluetoothConfiguration*>(source);
Q_ASSERT(usource != nullptr);
_device = usource->device();
}
Expand Down Expand Up @@ -338,7 +338,7 @@ void BluetoothConfiguration::setDevName(const QString &name)
}
}

QString BluetoothConfiguration::address()
QString BluetoothConfiguration::address() const
{
#ifdef Q_OS_IOS
return {};
Expand Down
16 changes: 8 additions & 8 deletions src/Comms/BluetoothLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class BluetoothConfiguration : public LinkConfiguration
public:

BluetoothConfiguration(const QString& name);
BluetoothConfiguration(BluetoothConfiguration* source);
BluetoothConfiguration(const BluetoothConfiguration* source);
~BluetoothConfiguration();

Q_PROPERTY(QString devName READ devName WRITE setDevName NOTIFY devNameChanged)
Expand All @@ -77,16 +77,16 @@ class BluetoothConfiguration : public LinkConfiguration
Q_INVOKABLE void startScan (void);
Q_INVOKABLE void stopScan (void);

QString devName (void) { return _device.name; }
QString address (void);
QStringList nameList (void) { return _nameList; }
bool scanning (void) { return _deviceDiscover != nullptr; }
BluetoothData device (void) { return _device; }
QString devName (void) const { return _device.name; }
QString address (void) const;
QStringList nameList (void) const { return _nameList; }
bool scanning (void) const { return _deviceDiscover != nullptr; }
BluetoothData device (void) const { return _device; }
void setDevName (const QString& name);

/// LinkConfiguration overrides
LinkType type (void) override { return LinkConfiguration::TypeBluetooth; }
void copyFrom (LinkConfiguration* source) override;
LinkType type (void) const override { return LinkConfiguration::TypeBluetooth; }
void copyFrom (const LinkConfiguration* source) override;
void loadSettings (QSettings& settings, const QString& root) override;
void saveSettings (QSettings& settings, const QString& root) override;
QString settingsURL (void) override { return "BluetoothSettings.qml"; }
Expand Down
22 changes: 11 additions & 11 deletions src/Comms/LinkConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LinkConfiguration::LinkConfiguration(const QString &name, QObject *parent)
// qCDebug(AudioOutputLog) << Q_FUNC_INFO << this;
}

LinkConfiguration::LinkConfiguration(LinkConfiguration *copy, QObject *parent)
LinkConfiguration::LinkConfiguration(const LinkConfiguration *copy, QObject *parent)
: QObject(parent)
, _link(copy->_link)
, _name(copy->name())
Expand All @@ -49,7 +49,7 @@ LinkConfiguration::~LinkConfiguration()
// qCDebug(AudioOutputLog) << Q_FUNC_INFO << this;
}

void LinkConfiguration::copyFrom(LinkConfiguration *source)
void LinkConfiguration::copyFrom(const LinkConfiguration *source)
{
Q_CHECK_PTR(source);

Expand Down Expand Up @@ -102,38 +102,38 @@ LinkConfiguration *LinkConfiguration::createSettings(int type, const QString &na
return config;
}

LinkConfiguration *LinkConfiguration::duplicateSettings(LinkConfiguration *source)
LinkConfiguration *LinkConfiguration::duplicateSettings(const LinkConfiguration *source)
{
LinkConfiguration *dupe = nullptr;

switch(source->type()) {
#ifndef NO_SERIAL_LINK
case TypeSerial:
dupe = new SerialConfiguration(qobject_cast<SerialConfiguration*>(source));
dupe = new SerialConfiguration(qobject_cast<const SerialConfiguration*>(source));
break;
#endif
case TypeUdp:
dupe = new UDPConfiguration(qobject_cast<UDPConfiguration*>(source));
dupe = new UDPConfiguration(qobject_cast<const UDPConfiguration*>(source));
break;
case TypeTcp:
dupe = new TCPConfiguration(qobject_cast<TCPConfiguration*>(source));
dupe = new TCPConfiguration(qobject_cast<const TCPConfiguration*>(source));
break;
#ifdef QGC_ENABLE_BLUETOOTH
case TypeBluetooth:
dupe = new BluetoothConfiguration(qobject_cast<BluetoothConfiguration*>(source));
dupe = new BluetoothConfiguration(qobject_cast<const BluetoothConfiguration*>(source));
break;
#endif
case TypeLogReplay:
dupe = new LogReplayLinkConfiguration(qobject_cast<LogReplayLinkConfiguration*>(source));
dupe = new LogReplayLinkConfiguration(qobject_cast<const LogReplayLinkConfiguration*>(source));
break;
#ifdef QT_DEBUG
case TypeMock:
dupe = new MockConfiguration(qobject_cast<MockConfiguration*>(source));
dupe = new MockConfiguration(qobject_cast<const MockConfiguration*>(source));
break;
#endif
#ifndef QGC_AIRLINK_DISABLED
case Airlink:
dupe = new AirlinkConfiguration(qobject_cast<AirlinkConfiguration*>(source));
dupe = new AirlinkConfiguration(qobject_cast<const AirlinkConfiguration*>(source));
break;
#endif
case TypeLast:
Expand All @@ -152,7 +152,7 @@ void LinkConfiguration::setName(const QString &name)
}
}

void LinkConfiguration::setLink(SharedLinkInterfacePtr link)
void LinkConfiguration::setLink(const SharedLinkInterfacePtr link)
{
if (link.get() != this->link()) {
_link = link;
Expand Down
10 changes: 5 additions & 5 deletions src/Comms/LinkConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class LinkConfiguration : public QObject

public:
LinkConfiguration(const QString &name, QObject *parent = nullptr);
LinkConfiguration(LinkConfiguration *copy, QObject *parent = nullptr);
LinkConfiguration(const LinkConfiguration *copy, QObject *parent = nullptr);
virtual ~LinkConfiguration();

QString name() const { return _name; }
void setName(const QString &name);

LinkInterface *link() { return _link.lock().get(); }
void setLink(std::shared_ptr<LinkInterface> link);
void setLink(const std::shared_ptr<LinkInterface> link);

/// Is this a dynamic configuration?
/// @return True if not persisted
Expand All @@ -62,7 +62,7 @@ class LinkConfiguration : public QObject
/// Copy instance data, When manipulating data, you create a copy of the configuration using the copy constructor,
/// edit it and then transfer its content to the original using this method.
/// @param[in] source The source instance (the edited copy)
virtual void copyFrom(LinkConfiguration *source);
virtual void copyFrom(const LinkConfiguration *source);

/// The link types supported by QGC
/// Any changes here MUST be reflected in LinkManager::linkTypeStrings()
Expand All @@ -88,7 +88,7 @@ class LinkConfiguration : public QObject

/// Connection type, pure virtual method returning one of the -TypeXxx types above.
/// @return The type of links these settings belong to.
virtual LinkType type() = 0;
virtual LinkType type() const = 0;

/// Load settings, Pure virtual method telling the instance to load its configuration.
/// @param[in] settings The QSettings instance to use
Expand All @@ -112,7 +112,7 @@ class LinkConfiguration : public QObject

/// Duplicate configuration instance. Helper method to create a new instance copy for editing.
/// @return A new copy of the given settings instance
static LinkConfiguration *duplicateSettings(LinkConfiguration *source);
static LinkConfiguration *duplicateSettings(const LinkConfiguration *source);

/// Root path for QSettings
/// @return The root path of the settings.
Expand Down
1 change: 1 addition & 0 deletions src/Comms/LinkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LinkInterface : public QThread
virtual bool isSecureConnection() { return false; } ///< Returns true if the connection is secure (e.g. USB, wired ethernet)

SharedLinkConfigurationPtr linkConfiguration() { return _config; }
const SharedLinkConfigurationPtr linkConfiguration() const { return _config; }
uint8_t mavlinkChannel() const;
bool mavlinkChannelIsSet() const;
bool isPX4Flow() const { return _isPX4Flow; }
Expand Down
Loading

0 comments on commit 008ae6e

Please sign in to comment.