summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdeviceinfo.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-01-29 19:06:59 +0100
committerOliver Wolff <oliver.wolff@qt.io>2018-08-17 06:28:17 +0000
commit0f930cddefe386c6b6f65b8b11342c9e76876a9b (patch)
tree546340d74090e05865bc4a28d27895ae969e1919 /src/bluetooth/qbluetoothdeviceinfo.cpp
parentc0960600bad55c5df62ba26a78d08179658b0454 (diff)
Add manufacturer data to QBluetoothDeviceInfo
The initial patch was contributed by Thiemo van Engelen. Change-Id: I45fad793ba092ab2820e606d8bf8807afa3e911e Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothdeviceinfo.cpp')
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index f068963e..ce557912 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -405,6 +405,7 @@ QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo
d->cached = other.d_func()->cached;
d->serviceUuidsCompleteness = other.d_func()->serviceUuidsCompleteness;
d->serviceUuids = other.d_func()->serviceUuids;
+ d->manufacturerData = other.d_func()->manufacturerData;
d->rssi = other.d_func()->rssi;
d->deviceCoreConfiguration = other.d_func()->deviceCoreConfiguration;
d->deviceUuid = other.d_func()->deviceUuid;
@@ -439,6 +440,8 @@ bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
return false;
if (d->serviceUuids != other.d_func()->serviceUuids)
return false;
+ if (d->manufacturerData != other.d_func()->manufacturerData)
+ return false;
if (d->deviceCoreConfiguration != other.d_func()->deviceCoreConfiguration)
return false;
if (d->deviceUuid != other.d_func()->deviceUuid)
@@ -557,10 +560,60 @@ QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids(DataCompleteness *compl
QBluetoothDeviceInfo::DataCompleteness QBluetoothDeviceInfo::serviceUuidsCompleteness() const
{
Q_D(const QBluetoothDeviceInfo);
-
return d->serviceUuidsCompleteness;
}
+
+/*!
+ Returns all manufacturer ids attached to this device information.
+
+ \sa manufacturerData(), setManufacturerData()
+
+ \since 5.12
+ */
+QVector<quint16> QBluetoothDeviceInfo::manufactuerIds() const
+{
+ Q_D(const QBluetoothDeviceInfo);
+ return d->manufacturerData.keys().toVector();
+}
+
+/*!
+ Returns the data associated with the given \a manufacturerId.
+
+ Manufacturer data is defined by
+ the Supplement to the Bluetooth Core Specification and consists of two segments:
+
+ \list
+ \li Manufacturer specific identifier code from the
+ \l {https://www.bluetooth.com/specifications/assigned-numbers} {Assigned Numbers}
+ Company Identifiers document
+ \li Sequence of arbitrary data octets
+ \endlist
+
+ The interpretation of the data octets is defined by the manufacturer
+ specified by the company identifier.
+
+ \sa manufacturerIds(), setManufacturerData()
+ \since 5.12
+ */
+QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
+{
+ Q_D(const QBluetoothDeviceInfo);
+ return d->manufacturerData.value(manufacturerId);
+}
+
+/*!
+ Sets the advertised manufacturer \a data for the given \a manufacturerId.
+
+ \sa manufacturerData,
+ \since 5.12
+*/
+void QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)
+{
+ Q_D(QBluetoothDeviceInfo);
+ d->manufacturerData.insert(manufacturerId, data);
+}
+
/*!
Sets the CoreConfigurations of the device to \a coreConfigs. This will help to make a difference
between regular and Low Energy devices.