Line data Source code
1 : // SPDX-FileCopyrightText: 2022-2025 Paul Colby <git@colby.id.au>
2 : // SPDX-License-Identifier: LGPL-3.0-or-later
3 :
4 : #include "scancommand.h"
5 :
6 : #include <qtpokit/pokitdiscoveryagent.h>
7 :
8 : #include <QBluetoothUuid>
9 : #include <QJsonArray>
10 : #include <QJsonDocument>
11 : #include <QJsonObject>
12 :
13 : #include <iostream>
14 :
15 : /*!
16 : * \class ScanCommand
17 : *
18 : * The ScanCommand class implements the `scan` CLI command, by scanning for nearby Pokit Bluetooth
19 : * devices. When devices are found, they are logged to stdout in the chosen format.
20 : */
21 :
22 : /*!
23 : * Construct a new ScanCommand object with \a parent.
24 : */
25 3177 : ScanCommand::ScanCommand(QObject * const parent) : AbstractCommand(parent)
26 2547 : {
27 2256 : #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // Required signal, and Fields, added in Qt 5.12.
28 4296 : connect(discoveryAgent, &PokitDiscoveryAgent::pokitDeviceUpdated,
29 2736 : this, &ScanCommand::deviceUpdated);
30 2256 : #endif
31 4785 : }
32 :
33 160 : QStringList ScanCommand::requiredOptions(const QCommandLineParser &parser) const
34 188 : {
35 348 : return AbstractCommand::requiredOptions(parser);
36 188 : }
37 :
38 80 : QStringList ScanCommand::supportedOptions(const QCommandLineParser &parser) const
39 94 : {
40 254 : return AbstractCommand::supportedOptions(parser) + QStringList{
41 234 : };
42 94 : }
43 :
44 : /// \copydoc AbstractCommand::processOptions
45 40 : QStringList ScanCommand::processOptions(const QCommandLineParser &parser)
46 47 : {
47 87 : QStringList errors = AbstractCommand::processOptions(parser);
48 47 : if (!errors.isEmpty()) {
49 0 : return errors;
50 0 : }
51 :
52 47 : return errors;
53 47 : }
54 :
55 : /*!
56 : * Begins scanning for Pokit devices.
57 : */
58 40 : bool ScanCommand::start()
59 17 : {
60 17 : Q_ASSERT(discoveryAgent);
61 124 : qCInfo(lc).noquote() << tr("Scanning for Pokit devices...");
62 57 : discoveryAgent->start();
63 57 : return true;
64 17 : }
65 :
66 : /*!
67 : * Handles discovered Pokit devices, writing \a info to stdout.
68 : */
69 3330 : void ScanCommand::deviceDiscovered(const QBluetoothDeviceInfo &info)
70 3825 : {
71 7155 : switch (format) {
72 1275 : case OutputFormat::Csv:
73 3816 : for (; showCsvHeader; showCsvHeader = false) {
74 1737 : std::cout << qUtf8Printable(tr("uuid,address,name,major_class,minor_class,signal_strength\n"));
75 765 : }
76 5355 : std::cout << qUtf8Printable(QString::fromLatin1("%1,%2,%3,%4,%5,%6\n").arg(info.deviceUuid().toString(),
77 1275 : info.address().toString(), escapeCsvField(info.name()), toString(info.majorDeviceClass()),
78 1275 : toString(info.majorDeviceClass(), info.minorDeviceClass())).arg(info.rssi()));
79 2385 : break;
80 2385 : case OutputFormat::Json:
81 3495 : std::cout << QJsonDocument(toJson(info)).toJson().toStdString();
82 2385 : break;
83 2385 : case OutputFormat::Text:
84 4845 : std::cout << qUtf8Printable(tr("%1 %2 %3 %4\n").arg(info.deviceUuid().toString(),
85 1275 : info.address().toString(), info.name()).arg(info.rssi()));
86 2385 : break;
87 3825 : }
88 7155 : }
89 :
90 : /*!
91 : * Handles updated Pokit devices, writing \a info to stdout. Currently \a updatedFields us unused.
92 : */
93 : #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // Required signal, and Fields, added in Qt 5.12.
94 1530 : void ScanCommand::deviceUpdated(const QBluetoothDeviceInfo &info,
95 : const QBluetoothDeviceInfo::Fields updatedFields)
96 1710 : {
97 1710 : Q_UNUSED(updatedFields)
98 3240 : deviceDiscovered(info);
99 3240 : }
100 : #endif
101 :
102 : /*!
103 : * Handles the completion of device discovery. In this override we simply exit, as the scan command
104 : * is nothing more than logging of discovered devices.
105 : */
106 40 : void ScanCommand::deviceDiscoveryFinished()
107 47 : {
108 97 : qCDebug(lc).noquote() << tr("Finished scanning for Pokit devices.");
109 87 : QCoreApplication::quit();
110 87 : }
111 :
112 : /*!
113 : * Returns \a info as a JSON object.
114 : */
115 1424 : QJsonObject ScanCommand::toJson(const QBluetoothDeviceInfo &info)
116 1642 : {
117 3066 : if (!info.isValid()) {
118 246 : return QJsonObject();
119 132 : }
120 1510 : QJsonObject json{
121 3850 : { QLatin1String("address"), info.address().toString() },
122 4130 : { QLatin1String("name"), info.name() },
123 2820 : { QLatin1String("isCached"), info.isCached() },
124 2820 : { QLatin1String("majorDeviceClass"), info.majorDeviceClass() },
125 3415 : { QLatin1String("majorDeviceClass"), toJson(info.majorDeviceClass()) },
126 3415 : { QLatin1String("minorDeviceClass"), toJson(info.majorDeviceClass(), info.minorDeviceClass()) },
127 3415 : { QLatin1String("signalStrength"), info.rssi() },
128 14280 : };
129 2820 : if (info.coreConfigurations() != QBluetoothDeviceInfo::UnknownCoreConfiguration) {
130 407 : json.insert(QLatin1String("coreConfiguration"), toJson(info.coreConfigurations()));
131 179 : }
132 2846 : if (!info.deviceUuid().isNull()) {
133 2539 : json.insert(QLatin1String("deviceUuid"), info.deviceUuid().toString());
134 953 : }
135 1330 : #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // Added in Qt 5.12.
136 2520 : if (!info.manufacturerData().isEmpty()) {
137 309 : json.insert(QLatin1String("manufacturerData"), toJson(info.manufacturerData()));
138 114 : }
139 1330 : #endif
140 2820 : if (info.serviceClasses() != QBluetoothDeviceInfo::NoService) {
141 493 : json.insert(QLatin1String("serviceClasses"), toJson(info.serviceClasses()));
142 217 : }
143 3415 : if (!info.serviceUuids().isEmpty()) {
144 124 : json.insert(QLatin1String("serviceUuids"), toJson(info.serviceUuids()));
145 47 : }
146 2320 : return json;
147 13077 : }
148 :
149 : /*!
150 : * Returns \a configuration as a JSON array of strings.
151 : */
152 314 : QJsonArray ScanCommand::toJson(const QBluetoothDeviceInfo::CoreConfigurations &configurations)
153 367 : {
154 681 : QJsonArray array;
155 367 : #define DOKIT_INTERNAL_IF_SET_THEN_APPEND(flag) \
156 1101 : if (configurations.testFlag(QBluetoothDeviceInfo::flag)) \
157 1101 : array.append(QLatin1String(#flag))
158 532 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(UnknownCoreConfiguration);
159 671 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(LowEnergyCoreConfiguration);
160 561 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(BaseRateCoreConfiguration);
161 : //DOKIT_INTERNAL_IF_SET_THEN_APPEND(BaseRateAndLowEnergyCoreConfiguration); // Combination flag.
162 367 : #undef DOKIT_INTERNAL_IF_SET_THEN_APPEND
163 681 : return array;
164 367 : }
165 :
166 : /*!
167 : * Returns \a majorClass as a JSON value. This is equivalent to toString, except that if toString
168 : * does not recognise \a majorClass, then \a majorClass is returned as a JSON number (not a string).
169 : *
170 : * \see toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass)
171 : */
172 1870 : QJsonValue ScanCommand::toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass)
173 2168 : {
174 4038 : const QString string = toString(majorClass);
175 5908 : return (string.isNull() ? QJsonValue(majorClass) : QJsonValue(string));
176 3205 : }
177 :
178 : /*!
179 : * Returns \a minorClass as a JSON value. This is equivalent to toString, except that if toString
180 : * does not recognise \a minorClass as a sub-class of \a majorClass, then \a minorClass is returned
181 : * as a JSON number (not a string).
182 : *
183 : * \see toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass)
184 : */
185 4990 : QJsonValue ScanCommand::toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass)
186 5834 : {
187 10824 : const QString string = toString(majorClass, minorClass);
188 15814 : return (string.isNull() ? QJsonValue(minorClass) : QJsonValue(string));
189 8665 : }
190 :
191 : /*!
192 : * Returns \a classes as a JSON array of strings.
193 : */
194 588 : QJsonArray ScanCommand::toJson(const QBluetoothDeviceInfo::ServiceClasses &classes)
195 687 : {
196 1275 : QJsonArray array;
197 687 : #define DOKIT_INTERNAL_IF_SET_THEN_APPEND(flag) \
198 5496 : if (classes.testFlag(QBluetoothDeviceInfo::flag)) \
199 5496 : array.append(QLatin1String(#flag))
200 1133 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(PositioningService);
201 1133 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(NetworkingService);
202 1133 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(RenderingService);
203 1104 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(CapturingService);
204 1104 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(ObjectTransferService);
205 1104 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(AudioService);
206 1104 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(TelephonyService);
207 1104 : DOKIT_INTERNAL_IF_SET_THEN_APPEND(InformationService);
208 687 : #undef DOKIT_INTERNAL_IF_SET_THEN_APPEND
209 1275 : return array;
210 687 : }
211 :
212 : /*!
213 : * Returns \a uuids as a JSON array.
214 : */
215 240 : QJsonArray ScanCommand::toJson(const QList<QBluetoothUuid> &uuids)
216 282 : {
217 522 : QJsonArray array;
218 1284 : for (const QBluetoothUuid &uuid: uuids) {
219 1296 : array.append(uuid.toString());
220 564 : }
221 522 : return array;
222 282 : }
223 :
224 : /*!
225 : * Returns Bluetooth manufacturer \a data as a JSON object that maps the manufacturer IDs (unsigned
226 : * integers as strings) to arrays of one or more values.
227 : */
228 238 : QJsonObject ScanCommand::toJson(const QMultiHash<quint16, QByteArray> &data)
229 266 : {
230 504 : QJsonObject object;
231 504 : QList<quint16> keys = data.uniqueKeys();
232 385 : std::sort(keys.begin(), keys.end());
233 958 : for (const quint16 key: keys) {
234 : // Convert the key's values to a JSON array, reversing the order, because QMultiHash
235 : // guarantees that the values are orderer "from the most recently inserted to the least
236 : // recently inserted", which is the oppoosit of what we want.
237 680 : QList<QByteArray> values = data.values(key);
238 550 : std::reverse(values.begin(), values.end());
239 720 : QJsonArray array;
240 1378 : for (const QByteArray &value: values) {
241 1719 : array.append(QLatin1String(value.toBase64()));
242 552 : }
243 890 : object.insert(QString::number(key), array);
244 720 : }
245 504 : return object;
246 385 : }
247 :
248 : /*!
249 : * Returns \a majorClass as a human-readable string, or a null QString if \a majorClass is not
250 : * recognised.
251 : *
252 : * For example, if \a majorClass is \c QBluetoothDeviceInfo::ToyDevice, then the string `ToyDevice`
253 : * is returned.
254 : */
255 3540 : QString ScanCommand::toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass)
256 4101 : {
257 4101 : #define DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(value) \
258 16981 : if (majorClass == QBluetoothDeviceInfo::value) \
259 16981 : return QLatin1String(#value)
260 7641 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(MiscellaneousDevice);
261 2399 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ComputerDevice);
262 1965 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(PhoneDevice);
263 336 : #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
264 336 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(LANAccessDevice); // Deprecated since Qt 5.13.
265 : #else
266 1107 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkDevice); // Added in Qt 5.13.
267 1015 : #endif
268 1349 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(AudioVideoDevice);
269 1255 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(PeripheralDevice);
270 1161 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ImagingDevice);
271 1067 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableDevice);
272 973 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyDevice);
273 879 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthDevice);
274 884 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedDevice);
275 282 : #undef DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN
276 582 : qCDebug(lc).noquote() << tr("Unknown major class %1.").arg(majorClass);
277 282 : return QString(); // Null QString indicates unknown minor class.
278 763 : }
279 :
280 : /*!
281 : * Returns \a minorClass as a human-readable string, or a null QString if \a minorClass is not
282 : * recognised as a sub-class of \a majorClass.
283 : *
284 : * For example, if \a majorClass is \c QBluetoothDeviceInfo::ToyDevice, and \a minorClass is
285 : * \c QBluetoothDeviceInfo::ToyRobot, then the string `ToyRobot` is returned.
286 : */
287 9780 : QString ScanCommand::toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass)
288 11433 : {
289 11433 : #define DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(value) \
290 50600 : if (minorClass == QBluetoothDeviceInfo::value) \
291 50600 : return QLatin1String(#value)
292 21213 : switch (majorClass) {
293 3558 : case QBluetoothDeviceInfo::MiscellaneousDevice:
294 3558 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedMiscellaneous);
295 434 : break;
296 2028 : case QBluetoothDeviceInfo::ComputerDevice:
297 1362 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedComputer);
298 1020 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(DesktopComputer);
299 926 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ServerComputer);
300 832 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(LaptopComputer);
301 738 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HandheldClamShellComputer);
302 644 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HandheldComputer);
303 550 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableComputer);
304 434 : break;
305 1854 : case QBluetoothDeviceInfo::PhoneDevice:
306 1246 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedPhone);
307 926 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(CellularPhone);
308 832 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(CordlessPhone);
309 738 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(SmartPhone);
310 644 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WiredModemOrVoiceGatewayPhone);
311 550 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(CommonIsdnAccessPhone);
312 434 : break;
313 84 : #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
314 396 : case QBluetoothDeviceInfo::LANAccessDevice: // Deprecated since Qt 5.13.
315 : #else
316 1170 : case QBluetoothDeviceInfo::NetworkDevice: // Added in Qt 5.13.
317 630 : #endif
318 1062 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkFullService);
319 774 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorOne);
320 680 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorTwo);
321 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorThree);
322 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorFour);
323 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorFive);
324 304 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkLoadFactorSix);
325 210 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(NetworkNoService);
326 94 : break;
327 3132 : case QBluetoothDeviceInfo::AudioVideoDevice:
328 2106 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedAudioVideoDevice);
329 1620 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableHeadsetDevice);
330 1526 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HandsFreeDevice);
331 1432 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(Microphone);
332 1338 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(Loudspeaker);
333 1244 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(Headphones);
334 1150 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(PortableAudioDevice);
335 1056 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(CarAudio);
336 962 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(SetTopBox);
337 868 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HiFiAudioDevice);
338 774 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(Vcr);
339 680 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(VideoCamera);
340 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(Camcorder);
341 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(VideoMonitor);
342 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(VideoDisplayAndLoudspeaker);
343 304 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(VideoConferencing);
344 210 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(GamingDevice);
345 94 : break;
346 1914 : case QBluetoothDeviceInfo::PeripheralDevice:
347 1294 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedPeripheral);
348 962 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(KeyboardPeripheral);
349 868 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(PointingDevicePeripheral);
350 774 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(KeyboardWithPointingDevicePeripheral);
351 680 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(JoystickPeripheral);
352 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(GamepadPeripheral);
353 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(RemoteControlPeripheral);
354 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(SensingDevicePeripheral);
355 304 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(DigitizerTabletPeripheral);
356 210 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(CardReaderPeripheral);
357 94 : break;
358 1044 : case QBluetoothDeviceInfo::ImagingDevice:
359 714 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedImagingDevice);
360 598 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ImageDisplay);
361 482 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ImageCamera);
362 366 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ImageScanner);
363 250 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ImagePrinter);
364 94 : break;
365 1218 : case QBluetoothDeviceInfo::WearableDevice:
366 830 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedWearableDevice);
367 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableWristWatch);
368 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearablePager);
369 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableJacket);
370 304 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableHelmet);
371 210 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(WearableGlasses);
372 94 : break;
373 1566 : case QBluetoothDeviceInfo::ToyDevice:
374 1062 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedToy);
375 774 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyRobot);
376 680 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyVehicle);
377 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyDoll);
378 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyController);
379 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(ToyGame);
380 282 : break;
381 1566 : case QBluetoothDeviceInfo::HealthDevice:
382 1062 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(UncategorizedHealthDevice);
383 774 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthBloodPressureMonitor);
384 680 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthThermometer);
385 586 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthWeightScale);
386 492 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthGlucoseMeter);
387 398 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthPulseOximeter);
388 304 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthDataDisplay);
389 210 : DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN(HealthStepCounter);
390 94 : break;
391 669 : case QBluetoothDeviceInfo::UncategorizedDevice:
392 : // There are no minor classes defined (in Qt) for uncategorized devices.
393 669 : break;
394 11433 : }
395 3099 : #undef DOKIT_INTERNAL_IF_EQUAL_THEN_RETURN
396 6453 : qCDebug(lc).noquote() << tr("Unknown minor class %1 for major class %2.")
397 0 : .arg(minorClass).arg(majorClass);
398 3099 : return QString(); // Null QString indicates unknown minor class.
399 11433 : }
|