From bc3baf27c23724497300fe0ded5e12995ce0e51d Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 18 Apr 2024 11:07:11 -0400 Subject: [PATCH] Update Bluetooth Configuration Usage --- src/comm/BluetoothLink.cc | 9 +++++---- src/comm/BluetoothLink.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/comm/BluetoothLink.cc b/src/comm/BluetoothLink.cc index 18927ba9b751..3fbd37c14f98 100644 --- a/src/comm/BluetoothLink.cc +++ b/src/comm/BluetoothLink.cc @@ -22,7 +22,8 @@ #include "LinkManager.h" BluetoothLink::BluetoothLink(SharedLinkConfigurationPtr& config) - : LinkInterface (config) + : LinkInterface(config) + , _bluetoothConfig(qobject_cast(config.get())) { } @@ -111,7 +112,7 @@ bool BluetoothLink::_hardwareConnect() _discoveryAgent->start(); #else _createSocket(); - _targetSocket->connectToService(QBluetoothAddress(qobject_cast(_config.get())->device().address), QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort)); + _targetSocket->connectToService(QBluetoothAddress(_bluetoothConfig->device().address), QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort)); #endif return true; } @@ -137,7 +138,7 @@ void BluetoothLink::serviceDiscovered(const QBluetoothServiceInfo& info) { if(!info.device().name().isEmpty() && !_targetSocket) { - if(_config->device().uuid == info.device().deviceUuid() && _config->device().name == info.device().name()) + if(_bluetoothConfig->device().uuid == info.device().deviceUuid() && _bluetoothConfig->device().name == info.device().name()) { _createSocket(); _targetSocket->connectToService(info); @@ -157,7 +158,7 @@ void BluetoothLink::discoveryFinished() if(!_targetSocket) { _connectState = false; - emit communicationError("Could not locate Bluetooth device:", _config->device().name); + emit communicationError("Could not locate Bluetooth device:", _bluetoothConfig->device().name); } } } diff --git a/src/comm/BluetoothLink.h b/src/comm/BluetoothLink.h index 6dee4813868e..f8b8f29a516d 100644 --- a/src/comm/BluetoothLink.h +++ b/src/comm/BluetoothLink.h @@ -147,6 +147,7 @@ private slots: bool _hardwareConnect (void); void _createSocket (void); + BluetoothConfiguration* _bluetoothConfig; QBluetoothSocket* _targetSocket = nullptr; #ifdef Q_OS_IOS QBluetoothServiceDiscoveryAgent* _discoveryAgent = nullptr;