Dokit
Internal development documentation
Loading...
Searching...
No Matches
scancommand.h
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
7{
9
10public:
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
16public slots:
17 QStringList processOptions(const QCommandLineParser &parser) override;
18 bool start() override;
19
20protected 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
28private:
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);
34 static QJsonValue toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass);
36 static QJsonArray toJson(const QList<QBluetoothUuid> &uuids);
38
40 static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass);
41
42 friend class TestScanCommand;
43};
The AbstractCommand class provides a consistent base for the classes that implement CLI commands.
The ScanCommand class implements the scan CLI command, by scanning for nearby Pokit Bluetooth devices...
Definition scancommand.h:7
static QJsonObject toJson(const QBluetoothDeviceInfo &info)
Returns info as a JSON object.
QStringList requiredOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names required by this command.
void deviceUpdated(const QBluetoothDeviceInfo &info, const QBluetoothDeviceInfo::Fields updatedFields)
Handles updated Pokit devices, writing info to stdout.
ScanCommand(QObject *const parent=nullptr)
Construct a new ScanCommand object with parent.
static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass)
Returns majorClass as a human-readable string, or a null QString if majorClass is not recognised.
void deviceDiscoveryFinished() override
Handles the completion of device discovery.
bool start() override
Begins scanning for Pokit devices.
QStringList processOptions(const QCommandLineParser &parser) override
Processes the relevant options from the command line parser.
bool showCsvHeader
Whether or not to show a header as the first line of CSV output.
Definition scancommand.h:29
void deviceDiscovered(const QBluetoothDeviceInfo &info) override
Handles discovered Pokit devices, writing info to stdout.
QStringList supportedOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names supported by this command.
Q_OBJECTQ_OBJECT
QObject * parent() const const