summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp62
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h5
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h2
3 files changed, 69 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index c0562c45..b8a68113 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -307,6 +307,37 @@ QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, con
}
/*!
+ Constructs a QBluetoothDeviceInfo object with unique \a uuid, device name
+ \a name and the encoded class of device \a classOfDevice.
+
+ This constructor is required for Low Energy devices on OS X and iOS. CoreBluetooth
+ API hides addresses and provides unique UUIDs to identify a device. This UUID is
+ not the same thing as a service UUID and is required to work later with CoreBluetooth API
+ and discovered devices.
+
+ \since 5.5
+*/
+QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
+ quint32 classOfDevice) :
+ d_ptr(new QBluetoothDeviceInfoPrivate)
+{
+ Q_D(QBluetoothDeviceInfo);
+
+ d->name = name;
+ d->deviceUuid = uuid;
+
+ d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
+ d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
+ d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
+
+ d->serviceUuidsCompleteness = DataUnavailable;
+
+ d->valid = true;
+ d->cached = false;
+ d->rssi = 0;
+}
+
+/*!
Constructs a QBluetoothDeviceInfo that is a copy of \a other.
*/
QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other) :
@@ -370,6 +401,7 @@ QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo
d->serviceUuids = other.d_func()->serviceUuids;
d->rssi = other.d_func()->rssi;
d->deviceCoreConfiguration = other.d_func()->deviceCoreConfiguration;
+ d->deviceUuid = other.d_func()->deviceUuid;
return *this;
}
@@ -403,6 +435,8 @@ bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
return false;
if (d->deviceCoreConfiguration != other.d_func()->deviceCoreConfiguration)
return false;
+ if (d->deviceUuid != other.d_func()->deviceUuid)
+ return false;
return true;
}
@@ -560,4 +594,32 @@ void QBluetoothDeviceInfo::setCached(bool cached)
d->cached = cached;
}
+/*!
+ Unique identifier for Bluetooth devices, that do not have addresses. This can happen on OS X and iOS,
+ where CoreBluetooth API hides addresses, but provides UUIDs to identify devices/peripherals.
+ This uuid is invalid on any other platform.
+
+ \sa deviceUuid()
+ \since 5.5
+ */
+void QBluetoothDeviceInfo::setDeviceUuid(const QBluetoothUuid &uuid)
+{
+ Q_D(QBluetoothDeviceInfo);
+
+ d->deviceUuid = uuid;
+}
+
+/*!
+ Unique identifier for a Bluetooth device without an address.
+
+ \sa setDeviceUuid()
+ \since 5.5
+ */
+QBluetoothUuid QBluetoothDeviceInfo::deviceUuid() const
+{
+ Q_D(const QBluetoothDeviceInfo);
+
+ return d->deviceUuid;
+}
+
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index ea8b7627..e86ea62e 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -199,6 +199,8 @@ public:
QBluetoothDeviceInfo();
QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name,
quint32 classOfDevice);
+ QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
+ quint32 classOfDevice);
QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other);
~QBluetoothDeviceInfo();
@@ -228,6 +230,9 @@ public:
void setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs);
QBluetoothDeviceInfo::CoreConfigurations coreConfigurations() const;
+ void setDeviceUuid(const QBluetoothUuid &uuid);
+ QBluetoothUuid deviceUuid() const;
+
protected:
QBluetoothDeviceInfoPrivate *d_ptr;
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 5b110993..d2a2d6ad 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -73,6 +73,8 @@ public:
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
QList<QBluetoothUuid> serviceUuids;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
+
+ QBluetoothUuid deviceUuid;
};
QT_END_NAMESPACE