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