Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qbluetoothuuid.h
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#ifndef QBLUETOOTHUUID_H
5#define QBLUETOOTHUUID_H
6
7#include <QtBluetooth/qtbluetoothglobal.h>
8
9#include <QtCore/QtGlobal>
10#include <QtCore/qhashfunctions.h>
11#include <QtCore/QMetaType>
12#include <QtCore/QUuid>
13
14#include <QtCore/QDebug>
15
16#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
17Q_FORWARD_DECLARE_OBJC_CLASS(CBUUID);
18#endif
19
20QT_BEGIN_NAMESPACE
21
22#if !defined(QT_SUPPORTS_INT128)
23struct quint128
24{
25 quint8 data[16];
26};
27#endif
28
29class Q_BLUETOOTH_EXPORT QBluetoothUuid : public QUuid
30{
31public:
32 enum class ProtocolUuid {
33 Sdp = 0x0001,
34 Udp = 0x0002,
35 Rfcomm = 0x0003,
36 Tcp = 0x0004,
37 TcsBin = 0x0005,
38 TcsAt = 0x0006,
39 Att = 0x0007,
40 Obex = 0x0008,
41 Ip = 0x0009,
42 Ftp = 0x000A,
43 Http = 0x000C,
44 Wsp = 0x000E,
45 Bnep = 0x000F,
46 Upnp = 0x0010,
47 Hidp = 0x0011,
48 HardcopyControlChannel = 0x0012,
49 HardcopyDataChannel = 0x0014,
50 HardcopyNotification = 0x0016,
51 Avctp = 0x0017,
52 Avdtp = 0x0019,
53 Cmtp = 0x001B,
54 UdiCPlain = 0x001D,
55 McapControlChannel = 0x001E,
56 McapDataChannel = 0x001F,
57 L2cap = 0x0100
58 };
59
60 enum class ServiceClassUuid {
61 ServiceDiscoveryServer = 0x1000,
62 BrowseGroupDescriptor = 0x1001,
63 PublicBrowseGroup = 0x1002,
64 SerialPort = 0x1101,
65 LANAccessUsingPPP = 0x1102,
66 DialupNetworking = 0x1103,
67 IrMCSync = 0x1104,
68 ObexObjectPush = 0x1105,
69 OBEXFileTransfer = 0x1106,
70 IrMCSyncCommand = 0x1107,
71 Headset = 0x1108,
72 AudioSource = 0x110a,
73 AudioSink = 0x110b,
74 AV_RemoteControlTarget = 0x110c,
75 AdvancedAudioDistribution = 0x110d,
76 AV_RemoteControl = 0x110e,
77 AV_RemoteControlController = 0x110f,
78 HeadsetAG = 0x1112,
79 PANU = 0x1115,
80 NAP = 0x1116,
81 GN = 0x1117,
82 DirectPrinting = 0x1118,
83 ReferencePrinting = 0x1119,
84 BasicImage = 0x111a,
85 ImagingResponder = 0x111b,
86 ImagingAutomaticArchive = 0x111c,
87 ImagingReferenceObjects = 0x111d,
88 Handsfree = 0x111e,
89 HandsfreeAudioGateway = 0x111f,
90 DirectPrintingReferenceObjectsService = 0x1120,
91 ReflectedUI = 0x1121,
92 BasicPrinting = 0x1122,
93 PrintingStatus = 0x1123,
94 HumanInterfaceDeviceService = 0x1124,
95 HardcopyCableReplacement = 0x1125,
96 HCRPrint = 0x1126,
97 HCRScan = 0x1127,
98 SIMAccess = 0x112d,
99 PhonebookAccessPCE = 0x112e,
100 PhonebookAccessPSE = 0x112f,
101 PhonebookAccess = 0x1130,
102 HeadsetHS = 0x1131,
103 MessageAccessServer = 0x1132,
104 MessageNotificationServer = 0x1133,
105 MessageAccessProfile = 0x1134,
106 GNSS = 0x1135,
107 GNSSServer = 0x1136,
108 Display3D = 0x1137,
109 Glasses3D = 0x1138,
110 Synchronization3D = 0x1139,
111 MPSProfile = 0x113a,
112 MPSService = 0x113b,
113 PnPInformation = 0x1200,
114 GenericNetworking = 0x1201,
115 GenericFileTransfer = 0x1202,
116 GenericAudio = 0x1203,
117 GenericTelephony = 0x1204,
118 VideoSource = 0x1303,
119 VideoSink = 0x1304,
120 VideoDistribution = 0x1305,
121 HDP = 0x1400,
122 HDPSource = 0x1401,
123 HDPSink = 0x1402,
124 GenericAccess = 0x1800,
125 GenericAttribute = 0x1801,
126 ImmediateAlert = 0x1802,
127 LinkLoss = 0x1803,
128 TxPower = 0x1804,
129 CurrentTimeService = 0x1805,
130 ReferenceTimeUpdateService = 0x1806,
131 NextDSTChangeService = 0x1807,
132 Glucose = 0x1808,
133 HealthThermometer = 0x1809,
134 DeviceInformation = 0x180a,
135 HeartRate = 0x180d,
136 PhoneAlertStatusService = 0x180e,
137 BatteryService = 0x180f,
138 BloodPressure = 0x1810,
139 AlertNotificationService = 0x1811,
140 HumanInterfaceDevice = 0x1812,
141 ScanParameters = 0x1813,
142 RunningSpeedAndCadence = 0x1814,
143 CyclingSpeedAndCadence = 0x1816,
144 CyclingPower = 0x1818,
145 LocationAndNavigation = 0x1819,
146 EnvironmentalSensing = 0x181a,
147 BodyComposition = 0x181b,
148 UserData = 0x181c,
149 WeightScale = 0x181d,
150 BondManagement = 0x181e,
151 ContinuousGlucoseMonitoring = 0x181f
152 };
153
154 enum class CharacteristicType {
155 DeviceName = 0x2a00,
156 Appearance = 0x2a01,
157 PeripheralPrivacyFlag = 0x2a02,
158 ReconnectionAddress = 0x2a03,
159 PeripheralPreferredConnectionParameters = 0x2a04,
160 ServiceChanged = 0x2a05,
161 AlertLevel = 0x2a06,
162 TxPowerLevel = 0x2a07,
163 DateTime = 0x2a08,
164 DayOfWeek = 0x2a09,
165 DayDateTime = 0x2a0a,
166 /* 0x2a0b not defined */
167 ExactTime256 = 0x2a0c,
168 DSTOffset = 0x2a0d,
169 TimeZone = 0x2a0e,
170 LocalTimeInformation = 0x2a0f,
171 /* 0x2a10 not defined */
172 TimeWithDST = 0x2a11,
173 TimeAccuracy = 0x2a12,
174 TimeSource = 0x2a13,
175 ReferenceTimeInformation = 0x2a14,
176 /* 0x2a15 not defined */
177 TimeUpdateControlPoint = 0x2a16,
178 TimeUpdateState = 0x2a17,
179 GlucoseMeasurement = 0x2a18,
180 BatteryLevel = 0x2a19,
181 /* 0x2a1a not defined */
182 /* 0x2a1b not defined */
183 TemperatureMeasurement = 0x2a1c,
184 TemperatureType = 0x2a1d,
185 IntermediateTemperature = 0x2a1e,
186 /* 0x2a1f not defined */
187 /* 0x2a20 not defined */
188 MeasurementInterval = 0x2a21,
189 BootKeyboardInputReport = 0x2a22,
190 SystemID = 0x2a23,
191 ModelNumberString = 0x2a24,
192 SerialNumberString = 0x2a25,
193 FirmwareRevisionString = 0x2a26,
194 HardwareRevisionString = 0x2a27,
195 SoftwareRevisionString = 0x2a28,
196 ManufacturerNameString = 0x2a29,
197 IEEE1107320601RegulatoryCertificationDataList = 0x2a2a,
198 CurrentTime = 0x2a2b,
199 MagneticDeclination = 0x2a2c,
200 /* 0x2a2d not defined */
201 /* 0x2a2e not defined */
202 /* 0x2a2f not defined */
203 /* 0x2a30 not defined */
204 ScanRefresh = 0x2a31,
205 BootKeyboardOutputReport = 0x2a32,
206 BootMouseInputReport = 0x2a33,
207 GlucoseMeasurementContext = 0x2a34,
208 BloodPressureMeasurement = 0x2a35,
209 IntermediateCuffPressure = 0x2a36,
210 HeartRateMeasurement = 0x2a37,
211 BodySensorLocation = 0x2a38,
212 HeartRateControlPoint = 0x2a39,
213 /* 0x2a3a not defined */
214 /* 0x2a3b not defined */
215 /* 0x2a3c not defined */
216 /* 0x2a3d not defined */
217 /* 0x2a3e not defined */
218 AlertStatus = 0x2a3f,
219 RingerControlPoint = 0x2a40,
220 RingerSetting = 0x2a41,
221 AlertCategoryIDBitMask = 0x2a42,
222 AlertCategoryID = 0x2a43,
223 AlertNotificationControlPoint = 0x2a44,
224 UnreadAlertStatus = 0x2a45,
225 NewAlert = 0x2a46,
226 SupportedNewAlertCategory = 0x2a47,
227 SupportedUnreadAlertCategory = 0x2a48,
228 BloodPressureFeature = 0x2a49,
229 HIDInformation = 0x2a4a,
230 ReportMap = 0x2a4b,
231 HIDControlPoint = 0x2a4c,
232 Report = 0x2a4d,
233 ProtocolMode = 0x2a4e,
234 ScanIntervalWindow = 0x2a4f,
235 PnPID = 0x2a50,
236 GlucoseFeature = 0x2a51,
237 RecordAccessControlPoint = 0x2a52,
238 RSCMeasurement = 0x2a53,
239 RSCFeature = 0x2a54,
240 SCControlPoint = 0x2a55,
241 /* 0x2a56 not defined */
242 /* 0x2a57 not defined */
243 /* 0x2a58 not defined */
244 /* 0x2a59 not defined */
245 /* 0x2a5a not defined */
246 CSCMeasurement = 0x2a5b,
247 CSCFeature = 0x2a5c,
248 SensorLocation = 0x2a5d,
249 /* 0x2a5e not defined */
250 /* 0x2a5f not defined */
251 /* 0x2a60 not defined */
252 /* 0x2a61 not defined */
253 /* 0x2a62 not defined */
254 CyclingPowerMeasurement = 0x2a63,
255 CyclingPowerVector = 0x2a64,
256 CyclingPowerFeature = 0x2a65,
257 CyclingPowerControlPoint = 0x2a66,
258 LocationAndSpeed = 0x2a67,
259 Navigation = 0x2a68,
260 PositionQuality = 0x2a69,
261 LNFeature = 0x2a6a,
262 LNControlPoint = 0x2a6b,
263 Elevation = 0x2a6c,
264 Pressure = 0x2a6d,
265 Temperature = 0x2a6e,
266 Humidity = 0x2a6f,
267 TrueWindSpeed = 0x2a70,
268 TrueWindDirection = 0x2a71,
269 ApparentWindSpeed = 0x2a72,
270 ApparentWindDirection = 0x2a73,
271 GustFactor = 0x2a74,
272 PollenConcentration = 0x2a75,
273 UVIndex = 0x2a76,
274 Irradiance = 0x2a77,
275 Rainfall = 0x2a78,
276 WindChill = 0x2a79,
277 HeatIndex = 0x2a7a,
278 DewPoint = 0x2a7b,
279 /* 0x2a7c not defined */
280 DescriptorValueChanged = 0x2a7d,
281 AerobicHeartRateLowerLimit = 0x2a7e,
282 AerobicThreshold = 0x2a7f,
283 Age = 0x2a80,
284 AnaerobicHeartRateLowerLimit = 0x2a81,
285 AnaerobicHeartRateUpperLimit = 0x2a82,
286 AnaerobicThreshold = 0x2a83,
287 AerobicHeartRateUpperLimit = 0x2a84,
288 DateOfBirth = 0x2a85,
289 DateOfThresholdAssessment = 0x2a86,
290 EmailAddress = 0x2a87,
291 FatBurnHeartRateLowerLimit = 0x2a88,
292 FatBurnHeartRateUpperLimit = 0x2a89,
293 FirstName = 0x2a8a,
294 FiveZoneHeartRateLimits = 0x2a8b,
295 Gender = 0x2a8c,
296 HeartRateMax = 0x2a8d,
297 Height = 0x2a8e,
298 HipCircumference = 0x2a8f,
299 LastName = 0x2a90,
300 MaximumRecommendedHeartRate = 0x2a91,
301 RestingHeartRate = 0x2a92,
302 SportTypeForAerobicAnaerobicThresholds = 0x2a93,
303 ThreeZoneHeartRateLimits = 0x2a94,
304 TwoZoneHeartRateLimits = 0x2a95,
305 VO2Max = 0x2a96,
306 WaistCircumference = 0x2a97,
307 Weight = 0x2a98,
308 DatabaseChangeIncrement = 0x2a99,
309 UserIndex = 0x2a9a,
310 BodyCompositionFeature = 0x2a9b,
311 BodyCompositionMeasurement = 0x2a9c,
312 WeightMeasurement = 0x2a9d,
313 WeightScaleFeature = 0x2a9e,
314 UserControlPoint = 0x2a9f,
315 MagneticFluxDensity2D = 0x2aa0,
316 MagneticFluxDensity3D = 0x2aa1,
317 Language = 0x2aa2,
318 BarometricPressureTrend = 0x2aa3
319 };
320
321 enum class DescriptorType {
322 UnknownDescriptorType = 0x0,
323 CharacteristicExtendedProperties = 0x2900,
324 CharacteristicUserDescription = 0x2901,
325 ClientCharacteristicConfiguration = 0x2902,
326 ServerCharacteristicConfiguration = 0x2903,
327 CharacteristicPresentationFormat = 0x2904,
328 CharacteristicAggregateFormat = 0x2905,
329 ValidRange = 0x2906,
330 ExternalReportReference = 0x2907,
331 ReportReference = 0x2908,
332 /* 0x2909 not defined */
333 /* 0x290a not defined */
334 EnvironmentalSensingConfiguration = 0x290b,
335 EnvironmentalSensingMeasurement = 0x290c,
336 EnvironmentalSensingTriggerSetting = 0x290d
337 };
338
339 constexpr QBluetoothUuid() noexcept {};
340
341 // values below are based on Bluetooth BASE_UUID
342 constexpr QBluetoothUuid(ProtocolUuid uuid) noexcept
343 : QBluetoothUuid(static_cast<quint32>(uuid)) {};
344 constexpr QBluetoothUuid(ServiceClassUuid uuid) noexcept
345 : QBluetoothUuid(static_cast<quint32>(uuid)) {};
346 constexpr QBluetoothUuid(CharacteristicType uuid) noexcept
347 : QBluetoothUuid(static_cast<quint32>(uuid)) {};
348 constexpr QBluetoothUuid(DescriptorType uuid) noexcept
349 : QBluetoothUuid(static_cast<quint32>(uuid)) {};
350 explicit constexpr QBluetoothUuid(quint16 uuid) noexcept
351 : QBluetoothUuid(quint32{uuid}) {};
352 explicit constexpr QBluetoothUuid(quint32 uuid) noexcept
353 : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
354 // end of bluetooth-specific constructors; rest is essentially `using QUuid::QUuid;`
355
356 using QUuid::QUuid;
357#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
358 explicit QBluetoothUuid(quint128 uuid);
359#endif
360 QT6_ONLY(QT_POST_CXX17_API_IN_EXPORTED_CLASS) // quint128 changes based on QT_SUPPORTS_INT128!
361 explicit QBluetoothUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept
362 : QUuid{fromBytes(&uuid, order)} {}
363#if QT_BLUETOOTH_REMOVED_SINCE(6, 6) // actually 6.3 (cf. QUuid)
364 explicit QBluetoothUuid(const QString &uuid);
365#endif
366 QBluetoothUuid(const QBluetoothUuid &uuid) = default;
367 QT_BLUETOOTH_INLINE_SINCE(6, 6)
368 QBluetoothUuid(QUuid QT6_ONLY(const &)uuid);
369 ~QBluetoothUuid() = default;
370
371 QBluetoothUuid &operator=(const QBluetoothUuid &other) = default;
372 friend bool operator==(const QBluetoothUuid &a, const QBluetoothUuid &b)
373 {
374 return static_cast<QUuid>(a) == static_cast<QUuid>(b);
375 }
376 friend bool operator!=(const QBluetoothUuid &a, const QBluetoothUuid &b) { return !(a == b); }
377#ifndef QT_NO_DEBUG_STREAM
378 friend Q_BLUETOOTH_EXPORT QDebug operator<<(QDebug debug, const QBluetoothUuid &uuid);
379#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
380 static QDebug streamingOperator(QDebug debug, const QBluetoothUuid &uuid);
381#endif
382#endif
383
384 int minimumSize() const;
385
386 quint16 toUInt16(bool *ok = nullptr) const;
387 quint32 toUInt32(bool *ok = nullptr) const;
388
389#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
390 quint128 toUInt128() const;
391#endif
392#if defined(Q_QDOC) || !defined(QT_SUPPORTS_INT128) // otherwise falls back to QUuid::toUint128()
393 quint128 toUInt128(QSysInfo::Endian order = QSysInfo::BigEndian) const noexcept;
394#endif
395
396#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
397 static QBluetoothUuid fromCBUUID(CBUUID *cbUuid);
398 CBUUID *toCBUUID() const Q_DECL_NS_RETURNS_AUTORELEASED;
399#endif
400
401 static QString serviceClassToString(ServiceClassUuid uuid);
402 static QString protocolToString(ProtocolUuid uuid);
403 static QString characteristicToString(CharacteristicType uuid);
404 static QString descriptorToString(DescriptorType uuid);
405
406private:
407 friend size_t qHash(QBluetoothUuid key, size_t seed = 0) noexcept
408 {
409 return QHashPrivate::ex1to2arg(QUuid{key}, seed);
410 }
411};
412
413#if QT_BLUETOOTH_INLINE_IMPL_SINCE(6, 6)
414QBluetoothUuid::QBluetoothUuid(QUuid QT6_ONLY(const &)uuid)
415 : QUuid(uuid)
416{
417}
418#endif
419
420
421#ifndef QT_NO_DATASTREAM
422inline QDataStream &operator<<(QDataStream &s, const QBluetoothUuid &uuid)
423{
424 return s << static_cast<const QUuid &>(uuid);
425}
426
427inline QDataStream &operator>>(QDataStream &s, QBluetoothUuid &uuid)
428{
429 return s >> static_cast<QUuid &>(uuid);
430}
431#endif
432
433QT_END_NAMESPACE
434
435QT_DECL_METATYPE_EXTERN(QBluetoothUuid, Q_BLUETOOTH_EXPORT)
436
437#endif
#define QT_BT_MAC_AUTORELEASEPOOL
Definition btutility_p.h:78
\inmodule QtBluetooth
\inmodule QtBluetooth
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
QList< QBluetoothUuid > includedServices
void setController(QLowEnergyControllerPrivate *control)
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
void characteristicRead(const QLowEnergyCharacteristic &info, const QByteArray &value)
QLowEnergyService::DiscoveryMode mode
void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue)
void descriptorRead(const QLowEnergyDescriptor &info, const QByteArray &value)
QLowEnergyService::ServiceError lastError
void setError(QLowEnergyService::ServiceError newError)
QLowEnergyService::ServiceTypes type
QPointer< QLowEnergyControllerPrivate > controller
void errorOccurred(QLowEnergyService::ServiceError error)
void setState(QLowEnergyService::ServiceState newState)
QLowEnergyService::ServiceState state
QHash< QLowEnergyHandle, CharData > characteristicList
ObjCStrongReference< NSError > qt_timeoutNSError(OperationTimeout type)
QQueue< LERequest > RequestQueue
QHash< NSObject *, QByteArray > ValueHash
auto qt_find_watchdog(const std::vector< GCDTimer > &watchdogs, id object, OperationTimeout type)
QHash< QLowEnergyHandle, CBDescriptor * > DescHash
QHash< QLowEnergyHandle, CBService * > ServiceHash
NSUInteger qt_countGATTEntries(CBService *service)
QHash< QLowEnergyHandle, CBCharacteristic * > CharHash
Combined button and popup list for selecting options.
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::CharData > CharacteristicDataMap
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::DescData > DescriptorDataMap
QDataStream & operator<<(QDataStream &stream, const QImage &image)
[0]
Definition qimage.cpp:4010
QDataStream & operator>>(QDataStream &stream, QImage &image)
Definition qimage.cpp:4036
QHash< QLowEnergyHandle, DescData > descriptorList
QLowEnergyCharacteristic::PropertyTypes properties