5#include <QtBluetooth/QBluetoothAddress>
6#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
7#include <QtBluetooth/QBluetoothDeviceInfo>
8#include <QtBluetooth/QBluetoothHostInfo>
9#include <QtBluetooth/QBluetoothLocalDevice>
10#include <QtCore/QFutureWatcher>
11#include <QtCore/QList>
12#include <QtCore/QPointer>
13#include <QtCore/QString>
14#include <QtCore/QVariantList>
15#include <QtQmlIntegration/QtQmlIntegration>
80 void loadSettings(QSettings &settings,
const QString &root)
override;
81 void saveSettings(QSettings &settings,
const QString &root)
const override;
82 QString
settingsURL()
const override {
return QStringLiteral(
"BluetoothSettings.qml"); }
88 const QBluetoothDeviceInfo&
device()
const {
return _device; }
90 QString
address()
const {
return _device.address().toString(); }
98 QString
serviceUuid()
const {
return _serviceUuid.toString(); }
100 QString
readUuid()
const {
return _readCharacteristicUuid.toString(); }
102 QString
writeUuid()
const {
return _writeCharacteristicUuid.toString(); }
111 static inline const QBluetoothUuid
NORDIC_UART_SERVICE{QStringLiteral(
"6e400001-b5a3-f393-e0a9-e50e24dcca9e")};
112 static inline const QBluetoothUuid
NORDIC_UART_RX_CHAR{QStringLiteral(
"6e400003-b5a3-f393-e0a9-e50e24dcca9e")};
113 static inline const QBluetoothUuid
NORDIC_UART_TX_CHAR{QStringLiteral(
"6e400002-b5a3-f393-e0a9-e50e24dcca9e")};
114 static inline const QBluetoothUuid
TI_SENSORTAG_SERVICE{QStringLiteral(
"0000ffe0-0000-1000-8000-00805f9b34fb")};
115 static inline const QBluetoothUuid
TI_SENSORTAG_CHAR{QStringLiteral(
"0000ffe1-0000-1000-8000-00805f9b34fb")};
132 void _deviceDiscovered(
const QBluetoothDeviceInfo &info);
133 void _onDiscoveryErrorOccurred(QBluetoothDeviceDiscoveryAgent::Error
error);
134 void _onDiscoveryFinished();
135 void _deviceUpdated(
const QBluetoothDeviceInfo &info, QBluetoothDeviceInfo::Fields updatedFields);
138 void _onHostModeStateChanged(QBluetoothLocalDevice::HostMode
mode);
139 void _onDeviceConnected(
const QBluetoothAddress &
address);
140 void _onDeviceDisconnected(
const QBluetoothAddress &
address);
141 void _onPairingFinished(
const QBluetoothAddress &
address, QBluetoothLocalDevice::Pairing pairing);
142 void _onLocalDeviceErrorOccurred(QBluetoothLocalDevice::Error
error);
145 void _initDeviceDiscoveryAgent();
146 void _refreshAvailableAdaptersAsync();
147 void _updateAvailableAdapters(
const QList<QBluetoothHostInfo> &hosts);
148 bool _ensureLocalDevice();
149 void _requestHostMode(QBluetoothLocalDevice::HostMode
mode);
150 void _updateDeviceList();
151 void _applySelectedDevice(
const QBluetoothDeviceInfo &info);
152 bool _createLocalDevice(
const QBluetoothAddress &
address);
153 void _connectLocalDeviceSignals();
154 bool _isDeviceCompatibleWithMode(
const QBluetoothDeviceInfo &info)
const;
157 QBluetoothDeviceInfo _device;
158 QList<QBluetoothDeviceInfo> _deviceList;
159 QVariantList _devicesModelCache;
160 QPointer<QBluetoothDeviceDiscoveryAgent> _deviceDiscoveryAgent;
161 QPointer<QBluetoothLocalDevice> _localDevice;
162 QVariantList _availableAdapters;
163 QPointer<QFutureWatcher<QList<QBluetoothHostInfo>>> _adapterWatcher;
164 bool _adapterEnumerationInProgress =
false;
165 bool _hostModeRequestPending =
false;
166 bool _deferredPowerOnFixPending =
false;
167 QBluetoothLocalDevice::HostMode _requestedHostMode = QBluetoothLocalDevice::HostPoweredOff;
168 bool _hasQueuedHostModeRequest =
false;
169 QBluetoothLocalDevice::HostMode _queuedHostMode = QBluetoothLocalDevice::HostPoweredOff;
170 qint16 _connectedRssi = 0;
void serviceUuidChanged()
static const QBluetoothUuid NORDIC_UART_SERVICE
static const QBluetoothUuid NORDIC_UART_RX_CHAR
void errorOccurred(const QString &errorString)
Q_INVOKABLE bool isDiscoverable() const
Q_INVOKABLE QString getAdapterAddress() const
Q_INVOKABLE void setDevice(const QString &name)
LinkType type() const override
Q_INVOKABLE QVariantList getAllPairedDevices() const
Q_INVOKABLE void requestPairing(const QString &address)
void devicesModelChanged()
void pairingStatusChanged()
Q_INVOKABLE void setAdapterDiscoverable(bool discoverable)
Q_INVOKABLE bool isAdapterAvailable() const
Q_INVOKABLE void powerOffAdapter()
qint16 selectedRssi() const
Q_INVOKABLE void selectAdapter(const QString &address)
Q_INVOKABLE QVariantList getConnectedDevices() const
Q_INVOKABLE void powerOnAdapter()
QString serviceUuid() const
void connectedRssiChanged()
void loadSettings(QSettings &settings, const QString &root) override
static bool isBluetoothAvailable()
Q_INVOKABLE QString getPairingStatus(const QString &address) const
const QBluetoothDeviceInfo & device() const
Q_INVOKABLE bool isPaired(const QString &address) const
void setMode(BluetoothMode mode)
QVariantList devicesModel() const
void selectedRssiChanged()
const QBluetoothUuid & writeCharacteristicUuid() const
const QBluetoothUuid & readCharacteristicUuid() const
void setConnectedRssi(qint16 rssi)
static const QBluetoothUuid TI_SENSORTAG_SERVICE
BluetoothMode mode() const
~BluetoothConfiguration() override
static const QBluetoothUuid NORDIC_UART_TX_CHAR
QString settingsTitle() const override
Settings Title, Pure virtual method providing the Title for the (QML) settings dialog.
qint16 connectedRssi() const
void saveSettings(QSettings &settings, const QString &root) const override
static const QBluetoothUuid TI_SENSORTAG_CHAR
void setWriteUuid(const QString &uuid)
Q_INVOKABLE bool isAdapterPoweredOn() const
QString settingsURL() const override
Settings URL, Pure virtual method providing the URL for the (QML) settings dialog.
Q_INVOKABLE void stopScan()
Q_INVOKABLE QVariantList getAllAvailableAdapters()
Q_INVOKABLE void removePairing(const QString &address)
Q_INVOKABLE QString getHostMode() const
Q_INVOKABLE void setDeviceByAddress(const QString &address)
void adapterStateChanged()
QString deviceName() const
void setServiceUuid(const QString &uuid)
Q_INVOKABLE void startScan()
Q_INVOKABLE QString getAdapterName() const
QString writeUuid() const
void setReadUuid(const QString &uuid)
void copyFrom(const LinkConfiguration *source) override
Interface holding link specific settings.
@ TypeBluetooth
Bluetooth Link.