diff options
Diffstat (limited to 'src/bluetooth/qbluetoothdeviceinfo.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothdeviceinfo.cpp | 62 |
1 files changed, 62 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 |