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