1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtBluetooth module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qbluetoothdeviceinfo.h"
41#include "qbluetoothdeviceinfo_p.h"
42
43QT_BEGIN_NAMESPACE
44
45/*!
46 \class QBluetoothDeviceInfo
47 \inmodule QtBluetooth
48 \brief The QBluetoothDeviceInfo class stores information about the Bluetooth
49 device.
50
51 \since 5.2
52
53 QBluetoothDeviceInfo provides information about a Bluetooth device's name, address and class of device.
54*/
55
56/*!
57 \enum QBluetoothDeviceInfo::MajorDeviceClass
58
59 This enum describes a Bluetooth device's major device class.
60
61 \value MiscellaneousDevice A miscellaneous device.
62 \value ComputerDevice A computer device or PDA.
63 \value PhoneDevice A telephone device.
64 \value LANAccessDevice A device that provides access to a local area network
65 (deprecated since Qt 5.13 and replaced by
66 \l QBluetoothDeviceInfo::NetworkDevice).
67 \value NetworkDevice A device that provides access to a local area network (since Qt 5.13).
68 \value AudioVideoDevice A device capable of playback or capture of audio and/or video.
69 \value PeripheralDevice A peripheral device such as a keyboard, mouse, and so on.
70 \value ImagingDevice An imaging device such as a display, printer, scanner or camera.
71 \value WearableDevice A wearable device such as a watch or pager.
72 \value ToyDevice A toy.
73 \value HealthDevice A health reated device such as heart rate or temperature monitor.
74 \value UncategorizedDevice A device that does not fit into any of the other device classes.
75*/
76
77/*!
78 \enum QBluetoothDeviceInfo::Field
79
80 This enum is used in conjuntion with the \l QBluetoothDeviceDiscoveryAgent::deviceUpdated() signal
81 and indicates the field that changed.
82
83 \value None None of the values changed.
84 \value RSSI The \l rssi() value of the device changed.
85 \value ManufacturerData The \l manufacturerData() field changed
86 \value All Matches every possible field.
87
88 \since 5.12
89*/
90
91/*!
92 \enum QBluetoothDeviceInfo::MinorMiscellaneousClass
93
94 This enum describes the minor device classes for miscellaneous Bluetooth devices.
95
96 \value UncategorizedMiscellaneous An uncategorized miscellaneous device.
97*/
98
99/*!
100 \enum QBluetoothDeviceInfo::MinorComputerClass
101
102 This enum describes the minor device classes for computer devices.
103
104 \value UncategorizedComputer An uncategorized computer device.
105 \value DesktopComputer A desktop computer.
106 \value ServerComputer A server computer.
107 \value LaptopComputer A laptop computer.
108 \value HandheldClamShellComputer A clamshell handheld computer or PDA.
109 \value HandheldComputer A handheld computer or PDA.
110 \value WearableComputer A wearable computer.
111*/
112
113/*!
114 \enum QBluetoothDeviceInfo::MinorPhoneClass
115
116 This enum describes the minor device classes for phone devices.
117
118 \value UncategorizedPhone An uncategorized phone device.
119 \value CellularPhone A cellular phone.
120 \value CordlessPhone A cordless phone.
121 \value SmartPhone A smart phone.
122 \value WiredModemOrVoiceGatewayPhone A wired modem or voice gateway.
123 \value CommonIsdnAccessPhone A device that provides ISDN access.
124*/
125
126/*!
127 \enum QBluetoothDeviceInfo::MinorNetworkClass
128
129 This enum describes the minor device classes for local area network access devices. Local area
130 network access devices use the minor device class to specify the current network utilization.
131
132 \value NetworkFullService 100% of the total bandwidth is available.
133 \value NetworkLoadFactorOne 0 - 17% of the total bandwidth is currently being used.
134 \value NetworkLoadFactorTwo 17 - 33% of the total bandwidth is currently being used.
135 \value NetworkLoadFactorThree 33 - 50% of the total bandwidth is currently being used.
136 \value NetworkLoadFactorFour 50 - 67% of the total bandwidth is currently being used.
137 \value NetworkLoadFactorFive 67 - 83% of the total bandwidth is currently being used.
138 \value NetworkLoadFactorSix 83 - 99% of the total bandwidth is currently being used.
139 \value NetworkNoService No network service available.
140*/
141
142/*!
143 \enum QBluetoothDeviceInfo::MinorAudioVideoClass
144
145 This enum describes the minor device classes for audio/video devices.
146
147 \value UncategorizedAudioVideoDevice An uncategorized audio/video device.
148 \value WearableHeadsetDevice A wearable headset device.
149 \value HandsFreeDevice A handsfree device.
150 \value Microphone A microphone.
151 \value Loudspeaker A loudspeaker.
152 \value Headphones Headphones.
153 \value PortableAudioDevice A portable audio device.
154 \value CarAudio A car audio device.
155 \value SetTopBox A settop box.
156 \value HiFiAudioDevice A HiFi audio device.
157 \value Vcr A video cassette recorder.
158 \value VideoCamera A video camera.
159 \value Camcorder A video camera.
160 \value VideoMonitor A video monitor.
161 \value VideoDisplayAndLoudspeaker A video display with built-in loudspeaker.
162 \value VideoConferencing A video conferencing device.
163 \value GamingDevice A gaming device.
164*/
165
166/*!
167 \enum QBluetoothDeviceInfo::MinorPeripheralClass
168
169 This enum describes the minor device classes for peripheral devices.
170
171 \value UncategorizedPeripheral An uncategorized peripheral device.
172 \value KeyboardPeripheral A keyboard.
173 \value PointingDevicePeripheral A pointing device, for example a mouse.
174 \value KeyboardWithPointingDevicePeripheral A keyboard with built-in pointing device.
175 \value JoystickPeripheral A joystick.
176 \value GamepadPeripheral A game pad.
177 \value RemoteControlPeripheral A remote control.
178 \value SensingDevicePeripheral A sensing device.
179 \value DigitizerTabletPeripheral A digitizer tablet peripheral.
180 \value CardReaderPeripheral A card reader peripheral.
181*/
182
183/*!
184 \enum QBluetoothDeviceInfo::MinorImagingClass
185
186 This enum describes the minor device classes for imaging devices.
187
188 \value UncategorizedImagingDevice An uncategorized imaging device.
189 \value ImageDisplay A device capable of displaying images.
190 \value ImageCamera A camera.
191 \value ImageScanner An image scanner.
192 \value ImagePrinter A printer.
193*/
194
195/*!
196 \enum QBluetoothDeviceInfo::MinorWearableClass
197
198 This enum describes the minor device classes for wearable devices.
199
200 \value UncategorizedWearableDevice An uncategorized wearable device.
201 \value WearableWristWatch A wristwatch.
202 \value WearablePager A pager.
203 \value WearableJacket A jacket.
204 \value WearableHelmet A helmet.
205 \value WearableGlasses A pair of glasses.
206*/
207
208/*!
209 \enum QBluetoothDeviceInfo::MinorToyClass
210
211 This enum describes the minor device classes for toy devices.
212
213 \value UncategorizedToy An uncategorized toy.
214 \value ToyRobot A toy robot.
215 \value ToyVehicle A toy vehicle.
216 \value ToyDoll A toy doll or action figure.
217 \value ToyController A controller.
218 \value ToyGame A game.
219*/
220
221/*!
222 \enum QBluetoothDeviceInfo::MinorHealthClass
223
224 This enum describes the minor device classes for health devices.
225
226 \value UncategorizedHealthDevice An uncategorized health device.
227 \value HealthBloodPressureMonitor A blood pressure monitor.
228 \value HealthThermometer A Thermometer.
229 \value HealthWeightScale A scale.
230 \value HealthGlucoseMeter A glucose meter.
231 \value HealthPulseOximeter A blood oxygen saturation meter.
232 \value HealthDataDisplay A data display.
233 \value HealthStepCounter A pedometer.
234*/
235
236/*!
237 \enum QBluetoothDeviceInfo::ServiceClass
238
239 This enum describes the service class of the Bluetooth device. The service class is used as a
240 rudimentary form of service discovery. It is meant to provide a list of the types
241 of services that the device might provide.
242
243 \value NoService The device does not provide any services.
244 \value PositioningService The device provides positioning services.
245 \value NetworkingService The device provides networking services.
246 \value RenderingService The device provides rendering services.
247 \value CapturingService The device provides capturing services.
248 \value ObjectTransferService The device provides object transfer services.
249 \value AudioService The device provides audio services.
250 \value TelephonyService The device provides telephony services.
251 \value InformationService The device provides information services.
252 \value AllServices The device provides services of all types.
253*/
254
255/*!
256 \enum QBluetoothDeviceInfo::DataCompleteness
257
258 This enum describes the completeness of the received data.
259
260 \value DataComplete The data is complete.
261 \value DataIncomplete The data is incomplete. Addition datum is available via other
262 interfaces.
263 \value DataUnavailable No data is available.
264*/
265
266/*!
267 \enum QBluetoothDeviceInfo::CoreConfiguration
268 \since 5.4
269
270 This enum describes the configuration of the device.
271
272 \value UnknownCoreConfiguration The type of the Bluetooth device cannot be determined.
273 \value BaseRateCoreConfiguration The device is a standard Bluetooth device.
274 \value BaseRateAndLowEnergyCoreConfiguration The device is a Bluetooth Smart device with support
275 for standard and Low Energy device.
276 \value LowEnergyCoreConfiguration The device is a Bluetooth Low Energy device.
277*/
278QBluetoothDeviceInfoPrivate::QBluetoothDeviceInfoPrivate() :
279 valid(false),
280 cached(false),
281 rssi(1),
282 serviceClasses(QBluetoothDeviceInfo::NoService),
283 majorDeviceClass(QBluetoothDeviceInfo::MiscellaneousDevice),
284 minorDeviceClass(0),
285 serviceUuidsCompleteness(QBluetoothDeviceInfo::DataUnavailable),
286 deviceCoreConfiguration(QBluetoothDeviceInfo::UnknownCoreConfiguration)
287{
288}
289
290/*!
291 Constructs an invalid QBluetoothDeviceInfo object.
292*/
293QBluetoothDeviceInfo::QBluetoothDeviceInfo() :
294 d_ptr(new QBluetoothDeviceInfoPrivate)
295{
296}
297
298/*!
299 Constructs a QBluetoothDeviceInfo object with Bluetooth address \a address, device name
300 \a name and the encoded class of device \a classOfDevice.
301
302 The \a classOfDevice parameter is encoded in the following format
303
304 \table
305 \header \li Bits \li Size \li Description
306 \row \li 0 - 1 \li 2 \li Unused, set to 0.
307 \row \li 2 - 7 \li 6 \li Minor device class.
308 \row \li 8 - 12 \li 5 \li Major device class.
309 \row \li 13 - 23 \li 11 \li Service class.
310 \endtable
311*/
312QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name,
313 quint32 classOfDevice) :
314 d_ptr(new QBluetoothDeviceInfoPrivate)
315{
316 Q_D(QBluetoothDeviceInfo);
317
318 d->address = address;
319 d->name = name;
320
321 d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
322 d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
323 d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
324
325 d->serviceUuidsCompleteness = DataUnavailable;
326
327 d->valid = true;
328 d->cached = false;
329 d->rssi = 0;
330}
331
332/*!
333 Constructs a QBluetoothDeviceInfo object with unique \a uuid, device name
334 \a name and the encoded class of device \a classOfDevice.
335
336 This constructor is required for Low Energy devices on \macos and iOS. CoreBluetooth
337 API hides addresses and provides unique UUIDs to identify a device. This UUID is
338 not the same thing as a service UUID and is required to work later with CoreBluetooth API
339 and discovered devices.
340
341 \since 5.5
342*/
343QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
344 quint32 classOfDevice) :
345 d_ptr(new QBluetoothDeviceInfoPrivate)
346{
347 Q_D(QBluetoothDeviceInfo);
348
349 d->name = name;
350 d->deviceUuid = uuid;
351
352 d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
353 d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
354 d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
355
356 d->serviceUuidsCompleteness = DataUnavailable;
357
358 d->valid = true;
359 d->cached = false;
360 d->rssi = 0;
361}
362
363/*!
364 Constructs a QBluetoothDeviceInfo that is a copy of \a other.
365*/
366QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other) :
367 d_ptr(new QBluetoothDeviceInfoPrivate)
368{
369 *this = other;
370}
371
372/*!
373 Destroys the QBluetoothDeviceInfo.
374*/
375QBluetoothDeviceInfo::~QBluetoothDeviceInfo()
376{
377 delete d_ptr;
378}
379
380/*!
381 Returns true if the QBluetoothDeviceInfo object is valid, otherwise returns false.
382*/
383bool QBluetoothDeviceInfo::isValid() const
384{
385 Q_D(const QBluetoothDeviceInfo);
386
387 return d->valid;
388}
389
390/*!
391 Returns the signal strength when the device was last scanned
392 */
393qint16 QBluetoothDeviceInfo::rssi() const
394{
395 Q_D(const QBluetoothDeviceInfo);
396
397 return d->rssi;
398}
399
400/*!
401 Set the \a signal strength value, used internally.
402 */
403void QBluetoothDeviceInfo::setRssi(qint16 signal)
404{
405 Q_D(QBluetoothDeviceInfo);
406 d->rssi = signal;
407}
408
409/*!
410 Makes a copy of the \a other and assigns it to this QBluetoothDeviceInfo object.
411*/
412QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo &other)
413{
414 Q_D(QBluetoothDeviceInfo);
415
416 d->address = other.d_func()->address;
417 d->name = other.d_func()->name;
418 d->minorDeviceClass = other.d_func()->minorDeviceClass;
419 d->majorDeviceClass = other.d_func()->majorDeviceClass;
420 d->serviceClasses = other.d_func()->serviceClasses;
421 d->valid = other.d_func()->valid;
422 d->cached = other.d_func()->cached;
423 d->serviceUuidsCompleteness = other.d_func()->serviceUuidsCompleteness;
424 d->serviceUuids = other.d_func()->serviceUuids;
425 d->manufacturerData = other.d_func()->manufacturerData;
426 d->rssi = other.d_func()->rssi;
427 d->deviceCoreConfiguration = other.d_func()->deviceCoreConfiguration;
428 d->deviceUuid = other.d_func()->deviceUuid;
429
430 return *this;
431}
432
433/*!
434 Returns true if the \a other QBluetoothDeviceInfo object and this are identical.
435 */
436bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
437{
438 Q_D(const QBluetoothDeviceInfo);
439
440 if (d->cached != other.d_func()->cached)
441 return false;
442 if (d->valid != other.d_func()->valid)
443 return false;
444 if (d->majorDeviceClass != other.d_func()->majorDeviceClass)
445 return false;
446 if (d->minorDeviceClass != other.d_func()->minorDeviceClass)
447 return false;
448 if (d->serviceClasses != other.d_func()->serviceClasses)
449 return false;
450 if (d->name != other.d_func()->name)
451 return false;
452 if (d->address != other.d_func()->address)
453 return false;
454 if (d->serviceUuidsCompleteness != other.d_func()->serviceUuidsCompleteness)
455 return false;
456 if (d->serviceUuids.count() != other.d_func()->serviceUuids.count())
457 return false;
458 if (d->serviceUuids != other.d_func()->serviceUuids)
459 return false;
460 if (d->manufacturerData != other.d_func()->manufacturerData)
461 return false;
462 if (d->deviceCoreConfiguration != other.d_func()->deviceCoreConfiguration)
463 return false;
464 if (d->deviceUuid != other.d_func()->deviceUuid)
465 return false;
466
467 return true;
468}
469
470/*!
471 Returns true if this object is different from \a other, or false otherwise.
472
473 \sa operator==()
474*/
475bool QBluetoothDeviceInfo::operator!=(const QBluetoothDeviceInfo &other) const
476{
477 return !(*this == other);
478}
479
480/*!
481 Returns the address of the device.
482
483 \note On iOS and \macos this address is invalid. Instead \l deviceUuid() should be used.
484 Those two platforms do not expose Bluetooth addresses for found Bluetooth devices
485 and utilize unique device identifiers.
486
487 \sa deviceUuid()
488*/
489QBluetoothAddress QBluetoothDeviceInfo::address() const
490{
491 Q_D(const QBluetoothDeviceInfo);
492
493 return d->address;
494}
495
496/*!
497 Returns the name assigned to the device.
498*/
499QString QBluetoothDeviceInfo::name() const
500{
501 Q_D(const QBluetoothDeviceInfo);
502
503 return d->name;
504}
505
506/*!
507 Returns the service class of the device.
508*/
509QBluetoothDeviceInfo::ServiceClasses QBluetoothDeviceInfo::serviceClasses() const
510{
511 Q_D(const QBluetoothDeviceInfo);
512
513 return d->serviceClasses;
514}
515
516/*!
517 Returns the major device class of the device.
518*/
519QBluetoothDeviceInfo::MajorDeviceClass QBluetoothDeviceInfo::majorDeviceClass() const
520{
521 Q_D(const QBluetoothDeviceInfo);
522
523 return d->majorDeviceClass;
524}
525
526/*!
527 Returns the minor device class of the device. The actual information
528 is context dependent on the value of \l majorDeviceClass().
529
530 \sa MinorAudioVideoClass, MinorComputerClass, MinorHealthClass, MinorImagingClass,
531 MinorMiscellaneousClass, MinorNetworkClass, MinorPeripheralClass, MinorPhoneClass,
532 MinorToyClass, MinorWearableClass
533*/
534quint8 QBluetoothDeviceInfo::minorDeviceClass() const
535{
536 Q_D(const QBluetoothDeviceInfo);
537
538 return d->minorDeviceClass;
539}
540
541/*!
542 \deprecated
543
544 Sets the list of service UUIDs to \a uuids and the completeness of the data to \a completeness.
545*/
546void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids,
547 DataCompleteness completeness)
548{
549 Q_D(QBluetoothDeviceInfo);
550
551 d->serviceUuids = uuids.toVector();
552 d->serviceUuidsCompleteness = completeness;
553}
554
555/*!
556 Sets the list of service UUIDs to \a uuids.
557 \since 5.13
558 */
559void QBluetoothDeviceInfo::setServiceUuids(const QVector<QBluetoothUuid> &uuids)
560{
561 Q_D(QBluetoothDeviceInfo);
562 d->serviceUuids = uuids;
563}
564
565#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
566/*!
567 Returns the list of service UUIDS supported by the device. Most commonly this
568 list of uuids represents custom uuids or a uuid value specified by
569 \l QBluetoothUuid::ServiceClassUuid.
570
571 \sa serviceUuids()
572 \since 6.0
573*/
574QVector<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const
575{
576 Q_D(const QBluetoothDeviceInfo);
577 return d->serviceUuids;
578}
579
580#else
581
582/*!
583 Returns the list of service UUIDS supported by the device. If \a completeness is not 0 it will
584 be set to DataComplete and the complete list of UUIDs supported by the device is returned.
585 DataIncomplete if additional service UUIDs are supported by the device and DataUnavailable if
586 no service UUID information is available.
587
588 This function requires both the Bluetooth devices to support the 2.1 specification.
589*/
590QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids(DataCompleteness *completeness) const
591{
592 Q_D(const QBluetoothDeviceInfo);
593
594 if (completeness)
595 *completeness = d->serviceUuidsCompleteness;
596
597 return d->serviceUuids.toList();
598}
599#endif //QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
600
601/*!
602 \deprecated
603
604 Returns the completeness of the service UUID list. If DataComplete is returned,
605 serviceUuids() returns the complete list of service UUIDs supported by the device, otherwise
606 only the partial or empty list of service UUIDs. To get a list
607 of all services supported by the device, a full service discovery needs to be performed.
608*/
609QBluetoothDeviceInfo::DataCompleteness QBluetoothDeviceInfo::serviceUuidsCompleteness() const
610{
611 Q_D(const QBluetoothDeviceInfo);
612 return d->serviceUuidsCompleteness;
613}
614
615
616/*!
617 Returns all manufacturer ids attached to this device information.
618
619 \sa manufacturerData(), setManufacturerData()
620
621 \since 5.12
622 */
623QVector<quint16> QBluetoothDeviceInfo::manufacturerIds() const
624{
625 Q_D(const QBluetoothDeviceInfo);
626 return d->manufacturerData.keys().toVector();
627}
628
629/*!
630 Returns the data associated with the given \a manufacturerId.
631
632 Manufacturer data is defined by
633 the Supplement to the Bluetooth Core Specification and consists of two segments:
634
635 \list
636 \li Manufacturer specific identifier code from the
637 \l {https://www.bluetooth.com/specifications/assigned-numbers} {Assigned Numbers}
638 Company Identifiers document
639 \li Sequence of arbitrary data octets
640 \endlist
641
642 The interpretation of the data octets is defined by the manufacturer
643 specified by the company identifier.
644
645 \sa manufacturerIds(), setManufacturerData()
646 \since 5.12
647 */
648QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
649{
650 Q_D(const QBluetoothDeviceInfo);
651 return d->manufacturerData.value(manufacturerId);
652}
653
654/*!
655 Sets the advertised manufacturer \a data for the given \a manufacturerId.
656 Returns true if it was inserted or changed, false if it was already known.
657
658 \sa manufacturerData
659 \since 5.12
660*/
661bool QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)
662{
663 Q_D(QBluetoothDeviceInfo);
664 const auto it = d->manufacturerData.find(manufacturerId);
665 if (it != d->manufacturerData.end() && *it == data)
666 return false;
667 d->manufacturerData.insert(manufacturerId, data);
668 return true;
669}
670
671/*!
672 Returns the complete set of all manufacturer data.
673
674 \sa setManufacturerData
675 \since 5.12
676*/
677QHash<quint16, QByteArray> QBluetoothDeviceInfo::manufacturerData() const
678{
679 Q_D(const QBluetoothDeviceInfo);
680 return d->manufacturerData;
681}
682
683/*!
684 Sets the CoreConfigurations of the device to \a coreConfigs. This will help to make a difference
685 between regular and Low Energy devices.
686
687 \sa coreConfigurations()
688 \since 5.4
689*/
690void QBluetoothDeviceInfo::setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs)
691{
692 Q_D(QBluetoothDeviceInfo);
693
694 d->deviceCoreConfiguration = coreConfigs;
695}
696
697/*!
698
699 Returns the configuration of the device. If device configuration is not set,
700 basic rate device configuration will be returned.
701
702 \sa setCoreConfigurations()
703 \since 5.4
704*/
705QBluetoothDeviceInfo::CoreConfigurations QBluetoothDeviceInfo::coreConfigurations() const
706{
707 Q_D(const QBluetoothDeviceInfo);
708
709 return d->deviceCoreConfiguration;
710}
711
712/*!
713 Returns true if the QBluetoothDeviceInfo object is created from cached data.
714*/
715bool QBluetoothDeviceInfo::isCached() const
716{
717 Q_D(const QBluetoothDeviceInfo);
718
719 return d->cached;
720}
721
722/*!
723 Used by the system to set the \a cached flag if the QBluetoothDeviceInfo is created from cached data. Cached
724 information may not be as accurate as data read from an active device.
725 */
726void QBluetoothDeviceInfo::setCached(bool cached)
727{
728 Q_D(QBluetoothDeviceInfo);
729
730 d->cached = cached;
731}
732
733/*!
734 Sets the unique identifier \a uuid for Bluetooth devices, that do not have addresses.
735 This happens on \macos and iOS, where the CoreBluetooth API hides addresses, but provides
736 UUIDs to identify devices/peripherals.
737
738 This uuid is invalid on any other platform.
739
740 \sa deviceUuid()
741 \since 5.5
742 */
743void QBluetoothDeviceInfo::setDeviceUuid(const QBluetoothUuid &uuid)
744{
745 Q_D(QBluetoothDeviceInfo);
746
747 d->deviceUuid = uuid;
748}
749
750/*!
751 Returns a unique identifier for a Bluetooth device without an address.
752
753 In general, this uuid is invalid on every platform but \macos and iOS.
754 It is used as a workaround for those two platforms as they do not
755 provide Bluetooth addresses for found Bluetooth Low Energy devices.
756 Every other platform uses \l address() instead.
757
758 \sa setDeviceUuid()
759 \since 5.5
760 */
761QBluetoothUuid QBluetoothDeviceInfo::deviceUuid() const
762{
763 Q_D(const QBluetoothDeviceInfo);
764
765 return d->deviceUuid;
766}
767
768QT_END_NAMESPACE
769