Line data Source code
1 : // SPDX-FileCopyrightText: 2022-2023 Paul Colby <git@colby.id.au> 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "abstractcommand.h" 5 : 6 910 : class ScanCommand : public AbstractCommand 7 : { 8 830 : Q_OBJECT 9 : 10 : public: 11 : explicit ScanCommand(QObject * const parent = nullptr); 12 : 13 : QStringList requiredOptions(const QCommandLineParser &parser) const override; 14 : QStringList supportedOptions(const QCommandLineParser &parser) const override; 15 : 16 : public slots: 17 : QStringList processOptions(const QCommandLineParser &parser) override; 18 : bool start() override; 19 : 20 : protected slots: 21 : void deviceDiscovered(const QBluetoothDeviceInfo &info) override; 22 : #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // Required signal, and Fields, added in Qt 5.12. 23 : void deviceUpdated(const QBluetoothDeviceInfo &info, 24 : const QBluetoothDeviceInfo::Fields updatedFields); 25 : #endif 26 : void deviceDiscoveryFinished() override; 27 : 28 : private: 29 : bool showCsvHeader { true }; ///< Whether or not to show a header as the first line of CSV output. 30 : 31 : static QJsonObject toJson(const QBluetoothDeviceInfo &info); 32 : static QJsonArray toJson(const QBluetoothDeviceInfo::CoreConfigurations &configurations); 33 : static QJsonValue toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass); 34 : static QJsonValue toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass); 35 : static QJsonArray toJson(const QBluetoothDeviceInfo::ServiceClasses &classes); 36 : static QJsonArray toJson(const QList<QBluetoothUuid> &uuids); 37 : static QJsonObject toJson(const QMultiHash<quint16, QByteArray> &data); 38 : 39 : static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass); 40 : static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass); 41 : 42 : friend class TestScanCommand; 43 : };