Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qbluetoothdeviceinfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
8
10#ifdef QT_WINRT_BLUETOOTH
11QT_IMPL_METATYPE_EXTERN_TAGGED(QBluetoothDeviceInfo::Fields, QBluetoothDeviceInfo__Fields)
12#endif
13
237
245
261 quint32 classOfDevice) :
263{
265
266 d->address = address;
267 d->name = name;
268
269 d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
270 d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
271 d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
272
273 d->valid = true;
274 d->cached = false;
275 d->rssi = 0;
276}
277
290 quint32 classOfDevice) :
292{
294
295 d->name = name;
296 d->deviceUuid = uuid;
297
298 d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
299 d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
300 d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
301
302 d->valid = true;
303 d->cached = false;
304 d->rssi = 0;
305}
306
315
323
328{
329 Q_D(const QBluetoothDeviceInfo);
330
331 return d->valid;
332}
333
338{
339 Q_D(const QBluetoothDeviceInfo);
340
341 return d->rssi;
342}
343
352
357{
359
360 d->address = other.d_func()->address;
361 d->name = other.d_func()->name;
362 d->minorDeviceClass = other.d_func()->minorDeviceClass;
363 d->majorDeviceClass = other.d_func()->majorDeviceClass;
364 d->serviceClasses = other.d_func()->serviceClasses;
365 d->valid = other.d_func()->valid;
366 d->cached = other.d_func()->cached;
367 d->serviceUuids = other.d_func()->serviceUuids;
368 d->manufacturerData = other.d_func()->manufacturerData;
369 d->serviceData = other.d_func()->serviceData;
370 d->rssi = other.d_func()->rssi;
371 d->deviceCoreConfiguration = other.d_func()->deviceCoreConfiguration;
372 d->deviceUuid = other.d_func()->deviceUuid;
373
374 return *this;
375}
376
393bool QBluetoothDeviceInfo::equals(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
394{
395 if (a.d_func()->cached != b.d_func()->cached)
396 return false;
397 if (a.d_func()->valid != b.d_func()->valid)
398 return false;
399 if (a.d_func()->majorDeviceClass != b.d_func()->majorDeviceClass)
400 return false;
401 if (a.d_func()->minorDeviceClass != b.d_func()->minorDeviceClass)
402 return false;
403 if (a.d_func()->serviceClasses != b.d_func()->serviceClasses)
404 return false;
405 if (a.d_func()->name != b.d_func()->name)
406 return false;
407 if (a.d_func()->address != b.d_func()->address)
408 return false;
409 if (a.d_func()->serviceUuids.size() != b.d_func()->serviceUuids.size())
410 return false;
411 if (a.d_func()->serviceUuids != b.d_func()->serviceUuids)
412 return false;
413 if (a.d_func()->manufacturerData != b.d_func()->manufacturerData)
414 return false;
415 if (a.d_func()->serviceData != b.d_func()->serviceData)
416 return false;
417 if (a.d_func()->deviceCoreConfiguration != b.d_func()->deviceCoreConfiguration)
418 return false;
419 if (a.d_func()->deviceUuid != b.d_func()->deviceUuid)
420 return false;
421
422 return true;
423}
424
435{
436 Q_D(const QBluetoothDeviceInfo);
437
438 return d->address;
439}
440
445{
446 Q_D(const QBluetoothDeviceInfo);
447
448 return d->name;
449}
450
457{
459
460 d->name = name;
461}
462
466QBluetoothDeviceInfo::ServiceClasses QBluetoothDeviceInfo::serviceClasses() const
467{
468 Q_D(const QBluetoothDeviceInfo);
469
470 return d->serviceClasses;
471}
472
477{
478 Q_D(const QBluetoothDeviceInfo);
479
480 return d->majorDeviceClass;
481}
482
492{
493 Q_D(const QBluetoothDeviceInfo);
494
495 return d->minorDeviceClass;
496}
497
502void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids)
503{
505 d->serviceUuids = uuids;
506}
507
516QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const
517{
518 Q_D(const QBluetoothDeviceInfo);
519 return d->serviceUuids;
520}
521
530{
531 Q_D(const QBluetoothDeviceInfo);
532 return d->manufacturerData.keys().toList();
533}
534
559{
560 Q_D(const QBluetoothDeviceInfo);
561 return d->manufacturerData.value(manufacturerId);
562}
563
575{
577 auto it = d->manufacturerData.constFind(manufacturerId);
578 while (it != d->manufacturerData.cend() && it.key() == manufacturerId) {
579 if (*it == data)
580 return false;
581 it++;
582 }
583
584 d->manufacturerData.insert(manufacturerId, data);
585 return true;
586}
587
599QMultiHash<quint16, QByteArray> QBluetoothDeviceInfo::manufacturerData() const
600{
601 Q_D(const QBluetoothDeviceInfo);
602 return d->manufacturerData;
603}
604
611QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceIds() const
612{
613 Q_D(const QBluetoothDeviceInfo);
614 return d->serviceData.keys().toList();
615}
616
636{
637 Q_D(const QBluetoothDeviceInfo);
638 return d->serviceData.value(serviceId);
639}
640
649{
651 auto it = d->serviceData.constFind(serviceId);
652 while (it != d->serviceData.cend() && it.key() == serviceId) {
653 if (*it == data)
654 return false;
655 it++;
656 }
657
658 d->serviceData.insert(serviceId, data);
659 return true;
660}
661
673QMultiHash<QBluetoothUuid, QByteArray> QBluetoothDeviceInfo::serviceData() const
674{
675 Q_D(const QBluetoothDeviceInfo);
676 return d->serviceData;
677}
678
686void QBluetoothDeviceInfo::setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs)
687{
689
690 d->deviceCoreConfiguration = coreConfigs;
691}
692
701QBluetoothDeviceInfo::CoreConfigurations QBluetoothDeviceInfo::coreConfigurations() const
702{
703 Q_D(const QBluetoothDeviceInfo);
704
705 return d->deviceCoreConfiguration;
706}
707
712{
713 Q_D(const QBluetoothDeviceInfo);
714
715 return d->cached;
716}
717
723{
725
726 d->cached = cached;
727}
728
740{
742
743 d->deviceUuid = uuid;
744}
745
758{
759 Q_D(const QBluetoothDeviceInfo);
760
761 return d->deviceUuid;
762}
763
\inmodule QtBluetooth
\inmodule QtBluetooth
~QBluetoothDeviceInfo()
Destroys the QBluetoothDeviceInfo.
QBluetoothDeviceInfoPrivate * d_ptr
QBluetoothDeviceInfo & operator=(const QBluetoothDeviceInfo &other)
Makes a copy of the other and assigns it to this QBluetoothDeviceInfo object.
QMultiHash< QBluetoothUuid, QByteArray > serviceData() const
Returns the complete set of all service data from advertisement packets.
QList< QBluetoothUuid > serviceIds() const
Returns all service data IDs from advertisement packets attached to this device information.
void setDeviceUuid(const QBluetoothUuid &uuid)
Sets the unique identifier uuid for Bluetooth devices, that do not have addresses.
QBluetoothAddress address() const
Returns the address of the device.
MajorDeviceClass
This enum describes a Bluetooth device's major device class.
QMultiHash< quint16, QByteArray > manufacturerData() const
Returns the complete set of all manufacturer data from advertisement packets.
quint8 minorDeviceClass() const
Returns the minor device class of the device.
bool isValid() const
Returns true if the QBluetoothDeviceInfo object is valid, otherwise returns false.
void setServiceUuids(const QList< QBluetoothUuid > &uuids)
Sets the list of service UUIDs to uuids.
void setRssi(qint16 signal)
Set the signal strength value, used internally.
void setCached(bool cached)
Used by the system to set the cached flag if the QBluetoothDeviceInfo is created from cached data.
QBluetoothDeviceInfo::CoreConfigurations coreConfigurations() const
Returns the configuration of the device.
ServiceClasses serviceClasses() const
Returns the service class of the device.
QList< quint16 > manufacturerIds() const
Returns all manufacturer IDs from advertisement packets attached to this device information.
QBluetoothUuid deviceUuid() const
Returns a unique identifier for a Bluetooth device without an address.
bool isCached() const
Returns true if the QBluetoothDeviceInfo object is created from cached data.
QList< QBluetoothUuid > serviceUuids() const
Returns the list of service UUIDs supported by the device.
bool setServiceData(const QBluetoothUuid &serviceId, const QByteArray &data)
Sets the advertised service data for the given serviceId.
MajorDeviceClass majorDeviceClass() const
Returns the major device class of the device.
QString name() const
Returns the name assigned to the device.
QBluetoothDeviceInfo()
Constructs an invalid QBluetoothDeviceInfo object.
void setName(const QString &name)
Sets the name of the device.
qint16 rssi() const
Returns the signal strength when the device was last scanned.
bool setManufacturerData(quint16 manufacturerId, const QByteArray &data)
Sets the advertised manufacturer data for the given manufacturerId.
void setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs)
Sets the CoreConfigurations of the device to coreConfigs.
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
const_iterator cend() const noexcept
Definition qset.h:142
const_iterator constFind(const T &value) const
Definition qset.h:161
iterator insert(const T &value)
Definition qset.h:155
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSet< QString >::iterator it
auto signal
Combined button and popup list for selecting options.
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1384
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLuint GLuint64EXT address
unsigned int quint32
Definition qtypes.h:50
short qint16
Definition qtypes.h:47
unsigned short quint16
Definition qtypes.h:48
unsigned char quint8
Definition qtypes.h:46
QSharedPointer< T > other(t)
[5]