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