4#include "infocommand.h"
9#include <QJsonDocument>
85 std::cout << qUtf8Printable(
tr(
"device_name,device_address,device_uuid,manufacturer_name,model_number,"
86 "hardware_revision,firmware_revision,software_revision,serial_number\n"));
106 if (!deviceAddress.
isNull()) {
109 if (!deviceUuid.
isNull()) {
112 if (!serialNumber.
isNull()) {
113 jsonObject.insert(
QLatin1String(
"serialNumber"), serialNumber);
119 std::cout << qUtf8Printable(
tr(
"Device name: %1\n").arg(deviceName));
121 if (!deviceAddress.
isNull()) {
122 std::cout << qUtf8Printable(
tr(
"Device addres: %1\n").arg(deviceAddress.
toString()));
124 if (!deviceUuid.
isNull()) {
125 std::cout << qUtf8Printable(
tr(
"Device UUID: %1\n").arg(deviceUuid.
toString()));
127 std::cout << qUtf8Printable(
tr(
"Manufacturer name: %1\n").arg(
service->manufacturer()));
128 std::cout << qUtf8Printable(
tr(
"Model number: %1\n").arg(
service->modelNumber()));
129 std::cout << qUtf8Printable(
tr(
"Hardware revision: %1\n").arg(
service->hardwareRevision()));
130 std::cout << qUtf8Printable(
tr(
"Firmware revision: %1\n").arg(
service->firmwareRevision()));
131 std::cout << qUtf8Printable(
tr(
"Software revision: %1\n").arg(
service->softwareRevision()));
132 if (!serialNumber.
isNull()) {
133 std::cout << qUtf8Printable(
tr(
"Serial number: %1\n").arg(serialNumber));
virtual QStringList supportedOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names supported by this command.
OutputFormat format
Selected output format.
@ Text
Plain unstructured text.
@ Csv
RFC 4180 compliant CSV text.
@ Json
RFC 8259 compliant JSON text.
virtual QStringList processOptions(const QCommandLineParser &parser)
Processes the relevant options from the command line parser.
static QString escapeCsvField(const QString &field)
Returns an RFC 4180 compliant version of field.
virtual QStringList requiredOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names required by this command.
The AbstractPokitService class provides a common base for Pokit services classes.
PokitDevice * device
Pokit Bluetooth device (if any) this command interracts with.
DeviceCommand(QObject *const parent=nullptr)
Construct a new DeviceCommand object with parent.
virtual void serviceDetailsDiscovered()
Handles service detail discovery events.
void disconnect(int exitCode=EXIT_SUCCESS)
Disconnects the underlying Pokit device, and sets exitCode to be return to the OS once the disconnect...
QStringList requiredOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names required by this command.
void serviceDetailsDiscovered() override
Handles service detail discovery events.
QStringList supportedOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names supported by this command.
DeviceInfoService * service
Bluetooth service this command interracts with.
AbstractPokitService * getService() override
Returns a Pokit service object for the derived command class.
QStringList processOptions(const QCommandLineParser &parser) override
Processes the relevant options from the command line parser.
InfoCommand(QObject *const parent=nullptr)
Construct a new InfoCommand object with parent.
Declares the DeviceInfoService class.
Declares the PokitDevice class.
bool isNull() const const
QString toString() const const
std::string toStdString() const const
QByteArray toJson() const const
bool isEmpty() const const
QBluetoothAddress remoteAddress() const const
QBluetoothUuid remoteDeviceUuid() const const
QString remoteName() const const
QObject * parent() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString fromLatin1(const char *str, int size)
bool isEmpty() const const
bool isNull() const const
bool isNull() const const
QString toString() const const