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 QBLUETOOTHDEVICEINFO_H
5#define QBLUETOOTHDEVICEINFO_H
6
7#include <QtBluetooth/qtbluetoothglobal.h>
8#include <QtBluetooth/QBluetoothUuid>
9
10#include <QtCore/qbytearray.h>
11#include <QtCore/qlist.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qstring.h>
14
15QT_BEGIN_NAMESPACE
16
17class QBluetoothDeviceInfoPrivate;
18class QBluetoothAddress;
19class QBluetoothUuid;
20
21class Q_BLUETOOTH_EXPORT QBluetoothDeviceInfo
22{
23public:
24 enum MajorDeviceClass {
25 MiscellaneousDevice = 0,
26 ComputerDevice = 1,
27 PhoneDevice = 2,
28 NetworkDevice = 3,
29 AudioVideoDevice = 4,
30 PeripheralDevice = 5,
31 ImagingDevice = 6,
32 WearableDevice = 7,
33 ToyDevice = 8,
34 HealthDevice = 9,
35 UncategorizedDevice = 31
36 };
37
38 enum MinorMiscellaneousClass {
39 UncategorizedMiscellaneous = 0
40 };
41
42 enum MinorComputerClass {
43 UncategorizedComputer = 0,
44 DesktopComputer = 1,
45 ServerComputer = 2,
46 LaptopComputer = 3,
47 HandheldClamShellComputer = 4,
48 HandheldComputer = 5,
49 WearableComputer = 6
50 };
51
52 enum MinorPhoneClass {
53 UncategorizedPhone = 0,
54 CellularPhone = 1,
55 CordlessPhone = 2,
56 SmartPhone = 3,
57 WiredModemOrVoiceGatewayPhone = 4,
58 CommonIsdnAccessPhone = 5
59 };
60
61 enum MinorNetworkClass {
62 NetworkFullService = 0x00,
63 NetworkLoadFactorOne = 0x08,
64 NetworkLoadFactorTwo = 0x10,
65 NetworkLoadFactorThree = 0x18,
66 NetworkLoadFactorFour = 0x20,
67 NetworkLoadFactorFive = 0x28,
68 NetworkLoadFactorSix = 0x30,
69 NetworkNoService = 0x38
70 };
71
72 enum MinorAudioVideoClass {
73 UncategorizedAudioVideoDevice = 0,
74 WearableHeadsetDevice = 1,
75 HandsFreeDevice = 2,
76 // reserved = 3,
77 Microphone = 4,
78 Loudspeaker = 5,
79 Headphones = 6,
80 PortableAudioDevice = 7,
81 CarAudio = 8,
82 SetTopBox = 9,
83 HiFiAudioDevice = 10,
84 Vcr = 11,
85 VideoCamera = 12,
86 Camcorder = 13,
87 VideoMonitor = 14,
88 VideoDisplayAndLoudspeaker = 15,
89 VideoConferencing = 16,
90 // reserved = 17,
91 GamingDevice = 18
92 };
93
94 enum MinorPeripheralClass {
95 UncategorizedPeripheral = 0,
96 KeyboardPeripheral = 0x10,
97 PointingDevicePeripheral = 0x20,
98 KeyboardWithPointingDevicePeripheral = 0x30,
99
100 JoystickPeripheral = 0x01,
101 GamepadPeripheral = 0x02,
102 RemoteControlPeripheral = 0x03,
103 SensingDevicePeripheral = 0x04,
104 DigitizerTabletPeripheral = 0x05,
105 CardReaderPeripheral = 0x06
106 };
107
108 enum MinorImagingClass {
109 UncategorizedImagingDevice = 0,
110 ImageDisplay = 0x04,
111 ImageCamera = 0x08,
112 ImageScanner = 0x10,
113 ImagePrinter = 0x20
114 };
115
116 enum MinorWearableClass {
117 UncategorizedWearableDevice = 0,
118 WearableWristWatch = 1,
119 WearablePager = 2,
120 WearableJacket = 3,
121 WearableHelmet = 4,
122 WearableGlasses = 5
123 };
124
125 enum MinorToyClass {
126 UncategorizedToy = 0,
127 ToyRobot = 1,
128 ToyVehicle = 2,
129 ToyDoll = 3,
130 ToyController = 4,
131 ToyGame = 5
132 };
133
134 enum MinorHealthClass {
135 UncategorizedHealthDevice = 0,
136 HealthBloodPressureMonitor = 0x1,
137 HealthThermometer = 0x2,
138 HealthWeightScale = 0x3,
139 HealthGlucoseMeter = 0x4,
140 HealthPulseOximeter = 0x5,
141 HealthDataDisplay = 0x7,
142 HealthStepCounter = 0x8
143 };
144
145 enum ServiceClass {
146 NoService = 0x0000,
147 PositioningService = 0x0001,
148 NetworkingService = 0x0002,
149 RenderingService = 0x0004,
150 CapturingService = 0x0008,
151 ObjectTransferService = 0x0010,
152 AudioService = 0x0020,
153 TelephonyService = 0x0040,
154 InformationService = 0x0080,
155 AllServices = 0x07ff
156 };
157 Q_DECLARE_FLAGS(ServiceClasses, ServiceClass)
158
159 enum class Field {
160 None = 0x0000,
161 RSSI = 0x0001,
162 ManufacturerData = 0x0002,
163 ServiceData = 0x0004,
164 All = 0x7fff
165 };
166 Q_DECLARE_FLAGS(Fields, Field)
167
168 enum CoreConfiguration {
169 UnknownCoreConfiguration = 0x0,
170 LowEnergyCoreConfiguration = 0x01,
171 BaseRateCoreConfiguration = 0x02,
172 BaseRateAndLowEnergyCoreConfiguration = 0x03
173 };
174 Q_DECLARE_FLAGS(CoreConfigurations, CoreConfiguration)
175
176 QBluetoothDeviceInfo();
177 QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name,
178 quint32 classOfDevice);
179 QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
180 quint32 classOfDevice);
181 QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other);
182 ~QBluetoothDeviceInfo();
183
184 bool isValid() const;
185 bool isCached() const;
186
187 void setCached(bool cached);
188
189 QBluetoothDeviceInfo &operator=(const QBluetoothDeviceInfo &other);
190 friend bool operator==(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
191 {
192 return equals(a, b);
193 }
194 friend bool operator!=(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
195 {
196 return !equals(a, b);
197 }
198
199 QBluetoothAddress address() const;
200 QString name() const;
201 void setName(const QString &name);
202
203 ServiceClasses serviceClasses() const;
204 MajorDeviceClass majorDeviceClass() const;
205 quint8 minorDeviceClass() const;
206
207 qint16 rssi() const;
208 void setRssi(qint16 signal);
209
210 QList<QBluetoothUuid> serviceUuids() const;
211 void setServiceUuids(const QList<QBluetoothUuid> &uuids);
212
213 QList<quint16> manufacturerIds() const;
214 QByteArray manufacturerData(quint16 manufacturerId) const;
215 bool setManufacturerData(quint16 manufacturerId, const QByteArray &data);
216 QMultiHash<quint16, QByteArray> manufacturerData() const;
217
218 QList<QBluetoothUuid> serviceIds() const;
219 QByteArray serviceData(const QBluetoothUuid &serviceId) const;
220 bool setServiceData(const QBluetoothUuid &serviceId, const QByteArray &data);
221 QMultiHash<QBluetoothUuid, QByteArray> serviceData() const;
222
223 void setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs);
224 QBluetoothDeviceInfo::CoreConfigurations coreConfigurations() const;
225
226 void setDeviceUuid(const QBluetoothUuid &uuid);
227 QBluetoothUuid deviceUuid() const;
228
229protected:
230 QBluetoothDeviceInfoPrivate *d_ptr;
231
232private:
233 static bool equals(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b);
234 Q_DECLARE_PRIVATE(QBluetoothDeviceInfo)
235};
236
237Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceInfo::CoreConfigurations)
238Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceInfo::ServiceClasses)
239
240QT_END_NAMESPACE
241
242QT_DECL_METATYPE_EXTERN(QBluetoothDeviceInfo, Q_BLUETOOTH_EXPORT)
243#ifdef QT_WINRT_BLUETOOTH
244QT_DECL_METATYPE_EXTERN_TAGGED(QBluetoothDeviceInfo::Fields, QBluetoothDeviceInfo__Fields,
245 Q_BLUETOOTH_EXPORT)
246#endif
247
248#endif
249

source code of qtconnectivity/src/bluetooth/qbluetoothdeviceinfo.h