diff --git a/src/Comms/BluetoothLink.cc b/src/Comms/BluetoothLink.cc index e2436da9b405..3cde10a59f0f 100644 --- a/src/Comms/BluetoothLink.cc +++ b/src/Comms/BluetoothLink.cc @@ -8,341 +8,257 @@ ****************************************************************************/ #include "BluetoothLink.h" -#include "DeviceInfo.h" + +#include +#include #include -#include #include +#include #ifdef Q_OS_IOS #include #else #include #endif -BluetoothLink::BluetoothLink(SharedLinkConfigurationPtr& config) - : LinkInterface(config) - , _bluetoothConfig(qobject_cast(config.get())) -{ - qRegisterMetaType(); - qRegisterMetaType(); -} +QGC_LOGGING_CATEGORY(BluetoothLinkLog, "qgc.comms.bluetoothlink") -BluetoothLink::~BluetoothLink() +BluetoothLink::BluetoothLink(SharedLinkConfigurationPtr &config, QObject *parent) + : LinkInterface(config, parent) + , _bluetoothConfig(qobject_cast(config.get())) + , _socket(new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this)) +#ifdef Q_OS_IOS + , _serviceDiscoveryAgent(new QBluetoothServiceDiscoveryAgent(this)) +#endif { - disconnect(); + // qCDebug(BluetoothLinkLog) << Q_FUNC_INFO << this; + + (void) qRegisterMetaType("QBluetoothServiceInfo"); + (void) qRegisterMetaType("QBluetoothDeviceInfo"); + + (void) QObject::connect(_socket, &QBluetoothSocket::connected, &BluetoothLink::connected, Qt::AutoConnection); + (void) QObject::connect(_socket, &QBluetoothSocket::disconnected, this, &BluetoothLink::disconnected, Qt::AutoConnection); #ifdef Q_OS_IOS - if(_discoveryAgent) { - _shutDown = true; - _discoveryAgent->stop(); - _discoveryAgent->deleteLater(); - _discoveryAgent = nullptr; - } + (void) QObject::connect(_serviceDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &BluetoothLink::_serviceDiscovered, Qt::AutoConnection); + (void) QObject::connect(_serviceDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::finished, this, &BluetoothLink::_discoveryFinished, Qt::AutoConnection); + (void) QObject::connect(_serviceDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::canceled, this, &BluetoothLink::_discoveryFinished, Qt::AutoConnection); #endif -} -void BluetoothLink::run() -{ + (void) QObject::connect(_socket, &QBluetoothSocket::errorOccurred, this, [this](QBluetoothSocket::SocketError error) { + qCWarning(BluetoothLinkLog) << "Bluetooth error:" << error << _socket->errorString(); + emit communicationError(QStringLiteral("Bluetooth Link Error"), QStringLiteral("Link: %1, %2.").arg(_bluetoothConfig->name(), _socket->errorString())); + }, Qt::AutoConnection); + (void) QObject::connect(_socket, &QBluetoothSocket::stateChanged, this, [](QBluetoothSocket::SocketState state) { + qCDebug(BluetoothLinkLog) << "State Changed:" << state; + }, Qt::AutoConnection); } -void BluetoothLink::_writeBytes(const QByteArray &bytes) +BluetoothLink::~BluetoothLink() { - if (_targetSocket) { - if(_targetSocket->write(bytes) > 0) { - emit bytesSent(this, bytes); - } else { - qWarning() << "Bluetooth write error"; - } - } + // qCDebug(BluetoothLinkLog) << Q_FUNC_INFO << this; } -void BluetoothLink::readBytes() +bool BluetoothLink::isConnected() const { - if (_targetSocket) { - while (_targetSocket->bytesAvailable() > 0) { - QByteArray datagram; - datagram.resize(_targetSocket->bytesAvailable()); - _targetSocket->read(datagram.data(), datagram.size()); - emit bytesReceived(this, datagram); - } - } + return ((_socket->state() != QBluetoothSocket::SocketState::ConnectedState) && (_socket->state() != QBluetoothSocket::SocketState::ConnectingState)); } -void BluetoothLink::disconnect(void) +void BluetoothLink::disconnect() { #ifdef Q_OS_IOS - if(_discoveryAgent) { - _shutDown = true; - _discoveryAgent->stop(); - _discoveryAgent->deleteLater(); - _discoveryAgent = nullptr; - } + (void) QMetaObject::invokeMethod(_serviceDiscoveryAgent, "stop", Qt::AutoConnection); +#else + _socket->disconnectFromService(); #endif - if(_targetSocket) { - // This prevents stale signals from calling the link after it has been deleted - QObject::disconnect(_targetSocket, &QBluetoothSocket::readyRead, this, &BluetoothLink::readBytes); - _targetSocket->deleteLater(); - _targetSocket = nullptr; - emit disconnected(); - } - _connectState = false; } -bool BluetoothLink::_connect(void) -{ - _hardwareConnect(); - return true; -} - -bool BluetoothLink::_hardwareConnect() +bool BluetoothLink::_connect() { #ifdef Q_OS_IOS - if(_discoveryAgent) { - _shutDown = true; - _discoveryAgent->stop(); - _discoveryAgent->deleteLater(); - _discoveryAgent = nullptr; - } - _discoveryAgent = new QBluetoothServiceDiscoveryAgent(this); - QObject::connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &BluetoothLink::serviceDiscovered); - QObject::connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::finished, this, &BluetoothLink::discoveryFinished); - QObject::connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::canceled, this, &BluetoothLink::discoveryFinished); - _shutDown = false; - _discoveryAgent->start(); + (void) QMetaObject::invokeMethod(_serviceDiscoveryAgent, "start", Qt::AutoConnection); #else - _createSocket(); - _targetSocket->connectToService(QBluetoothAddress(_bluetoothConfig->device().address), QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort)); + static constexpr QBluetoothUuid uuid = QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort); + _socket->connectToService(_bluetoothConfig->device().address, uuid); #endif + return true; } -void BluetoothLink::_createSocket() +void BluetoothLink::_writeBytes(const QByteArray &bytes) { - if(_targetSocket) - { - delete _targetSocket; - _targetSocket = nullptr; + if (_socket->write(bytes) > 0) { + emit bytesSent(this, bytes); + } else { + qCWarning(BluetoothLinkLog) << "Bluetooth write error"; } - _targetSocket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this); - QObject::connect(_targetSocket, &QBluetoothSocket::connected, this, &BluetoothLink::deviceConnected); - - QObject::connect(_targetSocket, &QBluetoothSocket::readyRead, this, &BluetoothLink::readBytes); - QObject::connect(_targetSocket, &QBluetoothSocket::disconnected, this, &BluetoothLink::deviceDisconnected); - - QObject::connect(_targetSocket, &QBluetoothSocket::errorOccurred, this, &BluetoothLink::deviceError); } -#ifdef Q_OS_IOS -void BluetoothLink::serviceDiscovered(const QBluetoothServiceInfo& info) +void BluetoothLink::_readBytes() { - if(!info.device().name().isEmpty() && !_targetSocket) - { - if(_bluetoothConfig->device().uuid == info.device().deviceUuid() && _bluetoothConfig->device().name == info.device().name()) - { - _createSocket(); - _targetSocket->connectToService(info); - } + qint64 byteCount; + if ((byteCount = _socket->bytesAvailable()) > 0) { + QByteArray buffer; + buffer.resize(byteCount); + (void) _socket->read(buffer.data(), buffer.size()); + emit bytesReceived(this, buffer); } } -#endif #ifdef Q_OS_IOS -void BluetoothLink::discoveryFinished() +void BluetoothLink::_serviceDiscovered(const QBluetoothServiceInfo &info) { - if(_discoveryAgent && !_shutDown) - { - _shutDown = true; - _discoveryAgent->deleteLater(); - _discoveryAgent = nullptr; - if(!_targetSocket) - { - _connectState = false; - emit communicationError("Could not locate Bluetooth device:", _bluetoothConfig->device().name); - } + if (info.device().name().isEmpty() || !info.isValid()) { + return; } -} -#endif - -void BluetoothLink::deviceConnected() -{ - _connectState = true; - emit connected(); -} - -void BluetoothLink::deviceDisconnected() -{ - _connectState = false; - qWarning() << "Bluetooth disconnected"; -} -void BluetoothLink::deviceError(QBluetoothSocket::SocketError error) -{ - _connectState = false; - qWarning() << "Bluetooth error" << error; - emit communicationError(tr("Bluetooth Link Error"), _targetSocket->errorString()); + if ((_bluetoothConfig->device().uuid == info.device().deviceUuid()) && (_bluetoothConfig->device().name == info.device().name())) { + _socket->connectToService(info); + } } -bool BluetoothLink::isConnected() const +void BluetoothLink::_discoveryFinished() { - return _connectState; + if (!isConnected()) { + _socket->disconnectFromService(); + emit communicationError(QStringLiteral("Could not locate Bluetooth device:"), _bluetoothConfig->device().name); + } } +#endif -//-------------------------------------------------------------------------- -//-- BluetoothConfiguration +//------------------------------------------------------------------------------ -BluetoothConfiguration::BluetoothConfiguration(const QString& name) - : LinkConfiguration(name) - , _deviceDiscover(nullptr) +BluetoothConfiguration::BluetoothConfiguration(const QString &name, QObject *parent) + : LinkConfiguration(name, parent) + , _deviceDiscoveryAgent(new QBluetoothDeviceDiscoveryAgent(this)) { + // qCDebug(BluetoothLinkLog) << Q_FUNC_INFO << this; + _initDeviceDiscoveryAgent(); } -BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration* source) - : LinkConfiguration(source) - , _deviceDiscover(nullptr) +BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration *source, QObject *parent) + : LinkConfiguration(source, parent) , _device(source->device()) + , _deviceDiscoveryAgent(new QBluetoothDeviceDiscoveryAgent(this)) { + // qCDebug(BluetoothLinkLog) << Q_FUNC_INFO << this; + + Q_CHECK_PTR(source); + + _initDeviceDiscoveryAgent(); } BluetoothConfiguration::~BluetoothConfiguration() { - if(_deviceDiscover) - { - _deviceDiscover->stop(); - delete _deviceDiscover; - } -} + stopScan(); -QString BluetoothConfiguration::settingsTitle() -{ - if(QGCDeviceInfo::isBluetoothAvailable()) { - return tr("Bluetooth Link Settings"); - } else { - return tr("Bluetooth Not Available"); - } + // qCDebug(BluetoothLinkLog) << Q_FUNC_INFO << this; } -void BluetoothConfiguration::copyFrom(LinkConfiguration *source) +void BluetoothConfiguration::_initDeviceDiscoveryAgent() { - LinkConfiguration::copyFrom(source); - auto* usource = qobject_cast(source); - Q_ASSERT(usource != nullptr); - _device = usource->device(); + (void) connect(_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BluetoothConfiguration::_deviceDiscovered, Qt::AutoConnection); + (void) connect(_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &BluetoothConfiguration::scanningChanged, Qt::AutoConnection); + (void) connect(_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &BluetoothConfiguration::scanningChanged, Qt::AutoConnection); + (void) connect(_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred, this, [](QBluetoothDeviceDiscoveryAgent::Error error) { + qCWarning(BluetoothLinkLog) << "Bluetooth Configuration error:" << error << _deviceDiscoveryAgent->errorString(); + }, Qt::AutoConnection); } -void BluetoothConfiguration::saveSettings(QSettings& settings, const QString& root) +void BluetoothConfiguration::startScan() { - settings.beginGroup(root); - settings.setValue("deviceName", _device.name); -#ifdef Q_OS_IOS - settings.setValue("uuid", _device.uuid.toString()); -#else - settings.setValue("address",_device.address); -#endif - settings.endGroup(); + _deviceList.clear(); + + _nameList.clear(); + emit nameListChanged(); + + (void) QMetaObject::invokeMethod(_deviceDiscoveryAgent, "start", Qt::AutoConnection); + emit scanningChanged(); } -void BluetoothConfiguration::loadSettings(QSettings& settings, const QString& root) +void BluetoothConfiguration::stopScan() { - settings.beginGroup(root); - _device.name = settings.value("deviceName", _device.name).toString(); -#ifdef Q_OS_IOS - QString suuid = settings.value("uuid", _device.uuid.toString()).toString(); - _device.uuid = QUuid(suuid); -#else - _device.address = settings.value("address", _device.address).toString(); -#endif - settings.endGroup(); + (void) QMetaObject::invokeMethod(_deviceDiscoveryAgent, "stop", Qt::AutoConnection); } -void BluetoothConfiguration::stopScan() +bool BluetoothConfiguration::scanning() const { - if(_deviceDiscover) - { - _deviceDiscover->stop(); - _deviceDiscover->deleteLater(); - _deviceDiscover = nullptr; - emit scanningChanged(); - } + return _deviceDiscoveryAgent->isActive(); } -void BluetoothConfiguration::startScan() +void BluetoothConfiguration::setDevice(const QString &name) { - if(!_deviceDiscover) { - _deviceDiscover = new QBluetoothDeviceDiscoveryAgent(this); - connect(_deviceDiscover, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BluetoothConfiguration::deviceDiscovered); - connect(_deviceDiscover, &QBluetoothDeviceDiscoveryAgent::finished, this, &BluetoothConfiguration::doneScanning); - emit scanningChanged(); - } else { - _deviceDiscover->stop(); + for (const BluetoothData &data: _deviceList) { + if (data.name == name) { + _device = data; + emit deviceChanged(); + return; + } } - _nameList.clear(); - _deviceList.clear(); - emit nameListChanged(); - _deviceDiscover->start(); } -void BluetoothConfiguration::deviceDiscovered(QBluetoothDeviceInfo info) +void BluetoothConfiguration::_deviceDiscovered(const QBluetoothDeviceInfo &info) { - if(!info.name().isEmpty() && info.isValid()) - { -#if 0 - qDebug() << "Name: " << info.name(); - qDebug() << "Address: " << info.address().toString(); - qDebug() << "Service Classes:" << info.serviceClasses(); - QList uuids = info.serviceUuids(); - for (QBluetoothUuid uuid: uuids) { - qDebug() << "Service UUID: " << uuid.toString(); - } -#endif + if (!info.name().isEmpty() && info.isValid()) { BluetoothData data; - data.name = info.name(); + data.name = info.name(); #ifdef Q_OS_IOS - data.uuid = info.deviceUuid(); + data.uuid = info.deviceUuid(); #else - data.address = info.address().toString(); + data.address = info.address(); #endif - if(!_deviceList.contains(data)) - { - _deviceList += data; - _nameList += data.name; + + if (!_deviceList.contains(data)) { + (void) _deviceList.append(data); + (void) _nameList.append(data.name); emit nameListChanged(); - return; } } } -void BluetoothConfiguration::doneScanning() +void BluetoothConfiguration::copyFrom(LinkConfiguration *source) { - if(_deviceDiscover) - { - _deviceDiscover->deleteLater(); - _deviceDiscover = nullptr; - emit scanningChanged(); - } + LinkConfiguration::copyFrom(source); + const BluetoothConfiguration* const bluetoothSource = qobject_cast(source); + Q_CHECK_PTR(bluetoothSource); + _device = bluetoothSource->device(); } -void BluetoothConfiguration::setDevName(const QString &name) +void BluetoothConfiguration::loadSettings(QSettings &settings, const QString &root) { - for(const BluetoothData& data: _deviceList) - { - if(data.name == name) - { - _device = data; - emit devNameChanged(); -#ifndef Q_OS_IOS - emit addressChanged(); + settings.beginGroup(root); + + _device.name = settings.value("deviceName", _device.name).toString(); +#ifdef Q_OS_IOS + const QString uuid = settings.value("uuid", _device.uuid.toString()).toString(); + _device.uuid = QUuid(uuid); +#else + _device.address = QBluetoothAddress(settings.value("address", _device.address.toString()).toString()); #endif - return; - } - } + + settings.endGroup(); } -QString BluetoothConfiguration::address() +void BluetoothConfiguration::saveSettings(QSettings &settings, const QString &root) { + settings.beginGroup(root); + + settings.setValue("deviceName", _device.name); #ifdef Q_OS_IOS - return {}; + settings.setValue("uuid", _device.uuid.toString()); #else - return _device.address; + settings.setValue("address",_device.address.toString()); #endif + + settings.endGroup(); +} + +QString BluetoothConfiguration::settingsTitle() +{ + if (QGCDeviceInfo::isBluetoothAvailable()) { + return QStringLiteral("Bluetooth Link Settings"); + } + + return QStringLiteral("Bluetooth Not Available"); } diff --git a/src/Comms/BluetoothLink.h b/src/Comms/BluetoothLink.h index 30f166c22f90..cb33f6c7aab5 100644 --- a/src/Comms/BluetoothLink.h +++ b/src/Comms/BluetoothLink.h @@ -9,10 +9,13 @@ #pragma once -#include -#include +#include #include #include +#include +#include +#include +#include #include "LinkConfiguration.h" #include "LinkInterface.h" @@ -23,25 +26,26 @@ #endif class QBluetoothDeviceDiscoveryAgent; -class BluetoothData +Q_DECLARE_LOGGING_CATEGORY(BluetoothLinkLog) + +struct BluetoothData { -public: - BluetoothData() - { - } - BluetoothData(const BluetoothData& other) + BluetoothData() = default; + BluetoothData(const BluetoothData &other) { *this = other; } - bool operator==(const BluetoothData& other) const + + bool operator==(const BluetoothData &other) const { #ifdef Q_OS_IOS - return uuid == other.uuid && name == other.name; + return ((uuid == other.uuid) && (name == other.name)); #else - return name == other.name && address == other.address; + return ((name == other.name) && (address == other.address)); #endif } - BluetoothData& operator=(const BluetoothData& other) + + BluetoothData& operator=(const BluetoothData &other) { name = other.name; #ifdef Q_OS_IOS @@ -49,110 +53,100 @@ class BluetoothData #else address = other.address; #endif + return *this; } + QString name; #ifdef Q_OS_IOS QBluetoothUuid uuid; #else - QString address; + QBluetoothAddress address; #endif }; +//------------------------------------------------------------------------------ + class BluetoothConfiguration : public LinkConfiguration { Q_OBJECT + Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceChanged) + Q_PROPERTY(QString address READ address NOTIFY deviceChanged) + Q_PROPERTY(QStringList nameList READ nameList NOTIFY nameListChanged) + Q_PROPERTY(bool scanning READ scanning NOTIFY scanningChanged) + public: + explicit BluetoothConfiguration(const QString &name, QObject *parent = nullptr); + explicit BluetoothConfiguration(BluetoothConfiguration *source, QObject *parent = nullptr); + virtual ~BluetoothConfiguration(); + + Q_INVOKABLE void startScan(); + Q_INVOKABLE void stopScan(); + Q_INVOKABLE void setDevice(const QString &name); + + BluetoothData device() const { return _device; } + QString deviceName() const { return _device.name; } +#ifdef Q_OS_IOS + QString address() const { return QString(); }; +#else + QString address() const { return _device.address.toString(); }; +#endif + QStringList nameList() const { return _nameList; } + bool scanning() const; - BluetoothConfiguration(const QString& name); - BluetoothConfiguration(BluetoothConfiguration* source); - ~BluetoothConfiguration(); - - Q_PROPERTY(QString devName READ devName WRITE setDevName NOTIFY devNameChanged) - Q_PROPERTY(QString address READ address NOTIFY addressChanged) - Q_PROPERTY(QStringList nameList READ nameList NOTIFY nameListChanged) - Q_PROPERTY(bool scanning READ scanning NOTIFY scanningChanged) - - 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; } - void setDevName (const QString& name); - - /// LinkConfiguration overrides - LinkType type (void) override { return LinkConfiguration::TypeBluetooth; } - void copyFrom (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"; } - QString settingsTitle (void) override; - -public slots: - void deviceDiscovered (QBluetoothDeviceInfo info); - void doneScanning (void); + LinkType type() override { return LinkConfiguration::TypeBluetooth; } + void copyFrom(LinkConfiguration *source) override; + void loadSettings(QSettings &settings, const QString &root) override; + void saveSettings(QSettings &settings, const QString &root) override; + QString settingsURL() override { return QStringLiteral("BluetoothSettings.qml"); } + QString settingsTitle() override; signals: - void newDevice (QBluetoothDeviceInfo info); - void devNameChanged (void); - void addressChanged (void); - void nameListChanged(void); - void scanningChanged(void); + void deviceChanged(); + void nameListChanged(); + void scanningChanged(); + +private slots: + void _deviceDiscovered(const QBluetoothDeviceInfo &info); private: - QBluetoothDeviceDiscoveryAgent* _deviceDiscover = nullptr; - BluetoothData _device; - QStringList _nameList; - QList _deviceList; + void _initDeviceDiscoveryAgent(); + + QList _deviceList; + BluetoothData _device{}; + QStringList _nameList; + QBluetoothDeviceDiscoveryAgent *_deviceDiscoveryAgent = nullptr; }; +//------------------------------------------------------------------------------ + class BluetoothLink : public LinkInterface { Q_OBJECT public: - BluetoothLink(SharedLinkConfigurationPtr& config); + explicit BluetoothLink(SharedLinkConfigurationPtr &config, QObject *parent = nullptr); virtual ~BluetoothLink(); - // Overrides from QThread - void run(void) override; - - // LinkConfiguration overrides - bool isConnected(void) const override; - void disconnect (void) override; - -public slots: - void readBytes (void); - void deviceConnected (void); - void deviceDisconnected (void); - void deviceError (QBluetoothSocket::SocketError error); -#ifdef Q_OS_IOS - void serviceDiscovered (const QBluetoothServiceInfo &info); - void discoveryFinished (void); -#endif + void run() override {}; + bool isConnected() const override; + void disconnect() override; private slots: - // LinkInterface overrides void _writeBytes(const QByteArray &bytes) override; + void _readBytes(); +#ifdef Q_OS_IOS + void _discoveryFinished(); + void _serviceDiscovered(const QBluetoothServiceInfo &info); +#endif private: + bool _connect() override; - // LinkInterface overrides - bool _connect(void) override; - - bool _hardwareConnect (void); - void _createSocket (void); - - BluetoothConfiguration* _bluetoothConfig; - QBluetoothSocket* _targetSocket = nullptr; + const BluetoothConfiguration *_bluetoothConfig = nullptr; + QBluetoothSocket *_socket = nullptr; #ifdef Q_OS_IOS - QBluetoothServiceDiscoveryAgent* _discoveryAgent = nullptr; + QBluetoothServiceDiscoveryAgent *_serviceDiscoveryAgent = nullptr; #endif - bool _shutDown = false; - bool _connectState = false; }; - diff --git a/src/UI/preferences/BluetoothSettings.qml b/src/UI/preferences/BluetoothSettings.qml index 48ae2b5be2da..54b59562afb3 100644 --- a/src/UI/preferences/BluetoothSettings.qml +++ b/src/UI/preferences/BluetoothSettings.qml @@ -31,7 +31,7 @@ ColumnLayout { QGCLabel { text: qsTr("Device") } QGCLabel { Layout.preferredWidth: _secondColumnWidth - text: subEditConfig.devName + text: subEditConfig.deviceName } QGCLabel { text: qsTr("Address") } @@ -54,7 +54,7 @@ ColumnLayout { onClicked: { checked = true if (modelData !== "") - subEditConfig.devName = modelData + subEditConfig.setDevice(modelData) } } }