summaryrefslogtreecommitdiffstats
path: root/src/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp2
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp4
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp57
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h8
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h2
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp2
6 files changed, 62 insertions, 13 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index 4bb003e2..f38f8994 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -175,8 +175,6 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT)
This signal informs you that if your application is displaying this data, it
can be updated, rather than waiting until the discovery has finished.
- \note This signal is only emitted on Android, iOS, macOS, and BlueZ 5.x.
-
\sa QBluetoothDeviceInfo::rssi(), lowEnergyDiscoveryTimeout()
*/
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 9d306053..7cabe9d0 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -882,9 +882,9 @@ void QBluetoothDeviceDiscoveryAgentPrivate::registerDevice(const QBluetoothDevic
// merge service uuids
QList<QBluetoothUuid> uuids = iter->serviceUuids();
uuids.append(info.serviceUuids());
- const QSet<QBluetoothUuid> uuidSet = uuids.toSet();
+ const QSet<QBluetoothUuid> uuidSet(uuids.begin(), uuids.end());
if (iter->serviceUuids().count() != uuidSet.count())
- iter->setServiceUuids(uuidSet.toList().toVector());
+ iter->setServiceUuids(uuidSet.values().toVector());
if (iter->coreConfigurations() != info.coreConfigurations())
iter->setCoreConfigurations(QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
return;
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index 46df5c7b..443902dc 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -282,7 +282,9 @@ QBluetoothDeviceInfoPrivate::QBluetoothDeviceInfoPrivate() :
serviceClasses(QBluetoothDeviceInfo::NoService),
majorDeviceClass(QBluetoothDeviceInfo::MiscellaneousDevice),
minorDeviceClass(0),
+#if QT_DEPRECATED_SINCE(5, 13)
serviceUuidsCompleteness(QBluetoothDeviceInfo::DataUnavailable),
+#endif
deviceCoreConfiguration(QBluetoothDeviceInfo::UnknownCoreConfiguration)
{
}
@@ -322,7 +324,9 @@ QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, con
d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
+#if QT_DEPRECATED_SINCE(5, 13)
d->serviceUuidsCompleteness = DataUnavailable;
+#endif
d->valid = true;
d->cached = false;
@@ -353,7 +357,9 @@ QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QSt
d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
+#if QT_DEPRECATED_SINCE(5, 13)
d->serviceUuidsCompleteness = DataUnavailable;
+#endif
d->valid = true;
d->cached = false;
@@ -420,7 +426,9 @@ QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo
d->serviceClasses = other.d_func()->serviceClasses;
d->valid = other.d_func()->valid;
d->cached = other.d_func()->cached;
+#if QT_DEPRECATED_SINCE(5, 13)
d->serviceUuidsCompleteness = other.d_func()->serviceUuidsCompleteness;
+#endif
d->serviceUuids = other.d_func()->serviceUuids;
d->manufacturerData = other.d_func()->manufacturerData;
d->rssi = other.d_func()->rssi;
@@ -451,8 +459,10 @@ bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
return false;
if (d->address != other.d_func()->address)
return false;
+#if QT_DEPRECATED_SINCE(5, 13)
if (d->serviceUuidsCompleteness != other.d_func()->serviceUuidsCompleteness)
return false;
+#endif
if (d->serviceUuids.count() != other.d_func()->serviceUuids.count())
return false;
if (d->serviceUuids != other.d_func()->serviceUuids)
@@ -538,6 +548,7 @@ quint8 QBluetoothDeviceInfo::minorDeviceClass() const
return d->minorDeviceClass;
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\deprecated
@@ -551,6 +562,7 @@ void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids,
d->serviceUuids = uuids.toVector();
d->serviceUuidsCompleteness = completeness;
}
+#endif
/*!
Sets the list of service UUIDs to \a uuids.
@@ -577,7 +589,7 @@ QVector<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const
return d->serviceUuids;
}
-#else
+#elif QT_DEPRECATED_SINCE(5, 13)
/*!
Returns the list of service UUIDS supported by the device. If \a completeness is not 0 it will
@@ -596,8 +608,23 @@ QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids(DataCompleteness *compl
return d->serviceUuids.toList();
}
+
+#else
+
+/*!
+ Returns the list of service UUIDS supported by the device. Most commonly this
+ list of uuids represents custom uuids or a uuid value specified by
+ \l QBluetoothUuid::ServiceClassUuid.
+*/
+QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const
+{
+ Q_D(const QBluetoothDeviceInfo);
+ return d->serviceUuids.toList();
+}
+
#endif //QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\deprecated
@@ -611,7 +638,7 @@ QBluetoothDeviceInfo::DataCompleteness QBluetoothDeviceInfo::serviceUuidsComplet
Q_D(const QBluetoothDeviceInfo);
return d->serviceUuidsCompleteness;
}
-
+#endif
/*!
Returns all manufacturer ids attached to this device information.
@@ -642,6 +669,10 @@ QVector<quint16> QBluetoothDeviceInfo::manufacturerIds() const
The interpretation of the data octets is defined by the manufacturer
specified by the company identifier.
+ \note The remote device may provide multiple data entries per manufacturerId.
+ This function only returns the first entry. If all entries are needed use
+ \l manufacturerData() which returns a multi hash.
+
\sa manufacturerIds(), setManufacturerData()
\since 5.12
*/
@@ -653,7 +684,10 @@ QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
/*!
Sets the advertised manufacturer \a data for the given \a manufacturerId.
- Returns true if it was inserted or changed, false if it was already known.
+ Returns \c true if it was inserted, \c false if it was already known.
+
+ Since Qt 5.14, different values for \a data and the same \a manufacturerId no longer
+ replace each other but are accumulated for the duration of a device scan.
\sa manufacturerData
\since 5.12
@@ -661,16 +695,25 @@ QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
bool QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)
{
Q_D(QBluetoothDeviceInfo);
- const auto it = d->manufacturerData.find(manufacturerId);
- if (it != d->manufacturerData.end() && *it == data)
- return false;
- d->manufacturerData.insert(manufacturerId, data);
+ QHash<quint16, QByteArray>::const_iterator it = d->manufacturerData.find(manufacturerId);
+ while (it != d->manufacturerData.end() && it.key() == manufacturerId) {
+ if (*it == data)
+ return false;
+ it++;
+ }
+
+ d->manufacturerData.insertMulti(manufacturerId, data);
return true;
}
/*!
Returns the complete set of all manufacturer data.
+ Some devices may provide multiple manufacturer data entries per manufacturer ID.
+ An example might be a Bluetooth Low Energy device that sends a different manufacturer data via
+ advertisement packets and scan response packets respectively. Therefore the returned hash table
+ may have multiple entries per manufacturer ID or hash key.
+
\sa setManufacturerData
\since 5.12
*/
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index 11cb2bea..c4fa01ec 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -255,11 +255,17 @@ public:
#ifndef Q_QDOC //suppress qdoc warnings
QVector<QBluetoothUuid> serviceUuids() const;
#endif // Q_QDOC
-#else
+#elif QT_DEPRECATED_SINCE(5, 13)
QList<QBluetoothUuid> serviceUuids(DataCompleteness *completeness = nullptr) const;
+#else
+ QList<QBluetoothUuid> serviceUuids() const;
#endif
void setServiceUuids(const QVector<QBluetoothUuid> &uuids);
+ // TODO Qt6 manufacturerData()
+ // manufacturerData() and manufacturerData(quint16) return types should be modified to
+ // cope with multiple data entires per manufacturer ID. QHash<quint16, QByteArray>
+ // may stay though if it retains insertMulti() in Qt 6.
QVector<quint16> manufacturerIds() const;
QByteArray manufacturerData(quint16 manufacturerId) const;
bool setManufacturerData(quint16 manufacturerId, const QByteArray &data);
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 3c19b10f..80fd1472 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -77,7 +77,9 @@ public:
QBluetoothDeviceInfo::MajorDeviceClass majorDeviceClass;
quint8 minorDeviceClass;
+#if QT_DEPRECATED_SINCE(5, 13)
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
+#endif
QVector<QBluetoothUuid> serviceUuids;
QHash<quint16, QByteArray> manufacturerData;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index f02c6ab9..f48717a6 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -1133,7 +1133,7 @@ void QBluetoothLocalDevicePrivate::createCache()
QList<QBluetoothAddress> QBluetoothLocalDevicePrivate::connectedDevices() const
{
- return connectedDevicesSet.toList();
+ return connectedDevicesSet.values();
}
void QBluetoothLocalDevice::pairingConfirmation(bool confirmation)