4#include "devicecommand.h"
32 ?
tr(
"Looking for first available Pokit device...")
44 qCDebug(lc).noquote() <<
tr(
"Disconnecting Pokit device...");
60#define DOKIT_CLI_IF_LESS_THAN_RETURN(value, ns, label) \
61if (value <= ns::maxValue(label).toUInt()) { \
217 Q_ASSERT_X(
false,
"DeviceCommand::minCapacitanceRange",
"Pokit Meter has no capacitance support.");
222 Q_ASSERT_X(
false,
"DeviceCommand::minCapacitanceRange",
"Unknown PokitProduct enum value");
241 Q_ASSERT_X(
false,
"DeviceCommand::minCurrentRange",
"Unknown PokitProduct enum value");
260 Q_ASSERT_X(
false,
"DeviceCommand::minResistanceRange",
"Unknown PokitProduct enum value");
280 Q_ASSERT_X(
false,
"DeviceCommand::minVoltageRange",
"Unknown PokitProduct enum value");
284#undef DOKIT_CLI_IF_LESS_THAN_RETURN
294 qCWarning(lc).noquote() <<
tr(
"Bluetooth controller error:") << error;
307 qCDebug(lc).noquote() <<
tr(
"Pokit device disconnected. Exiting with code %1.")
322 qCWarning(lc).noquote() <<
tr(
"Bluetooth service error:") << error;
333 qCDebug(lc).noquote() <<
tr(
"Service details discovered.");
345 qCDebug(lc).noquote() <<
tr(R
"(Ignoring additional Pokit device "%1" (%2) at (%3).)")
354 qCDebug(lc).noquote() <<
tr(R
"(Found Pokit device "%1" (%2) at (%3).)")
362 #if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
365 &QLowEnergyController::errorOccurred,
378 qCDebug(lc).noquote() <<
tr(R
"(Connecting to %1 device "%2" (%3) at (%4).)").arg(
384 qCDebug(lc).noquote() <<
tr(R
"(Ignoring non-matching Pokit device "%1" (%2) at (%3).)")
396 ?
tr(
"Failed to find any Pokit device.")
Declares the AbstractPokitService class.
The AbstractCommand class provides a consistent base for the classes that implement CLI commands.
QString deviceToScanFor
Device (if any) that were passed to processOptions().
PokitDiscoveryAgent * discoveryAgent
Agent for Pokit device descovery.
The AbstractPokitService class provides a common base for Pokit services classes.
std::optional< PokitProduct > pokitProduct() const
Returns the Pokit product this service is attached to.
void serviceErrorOccurred(QLowEnergyService::ServiceError newError)
This signal is emitted whenever an error occurs on the underlying QLowEnergyService.
void setPokitProduct(const PokitProduct product)
Sets the current Pokit product.
void serviceDetailsDiscovered()
This signal is emitted when the Pokit service details have been discovered.
static quint8 minResistanceRange(const PokitProduct product, const quint32 maxValue)
Returns the product's lowest resistance range that can measure at least up to maxValue (Ω),...
virtual void controllerError(const QLowEnergyController::Error error)
Handles controller error events.
PokitDevice * device
Pokit Bluetooth device (if any) this command interracts with.
virtual void deviceDisconnected()
Handles devics disconnection events.
DeviceCommand(QObject *const parent=nullptr)
Construct a new DeviceCommand object with parent.
bool start() override
Begins scanning for the Pokit device.
int exitCodeOnDisconnect
Exit code to return on device disconnection.
void deviceDiscoveryFinished() override
Checks that the requested device was discovered, and if not, reports and error and exits.
static quint8 minCapacitanceRange(const PokitProduct product, const quint32 maxValue)
Returns the product's lowest capacitance range that can measure at least up to maxValue (nF),...
virtual void serviceDetailsDiscovered()
Handles service detail discovery events.
static quint8 minVoltageRange(const PokitProduct product, const quint32 maxValue)
t Returns the product's lowest voltage range that can measure at least up to maxValue (mV),...
virtual void serviceError(const QLowEnergyService::ServiceError error)
Handles service error events.
static quint8 minCurrentRange(const PokitProduct product, const quint32 maxValue)
Returns the product's lowest current range that can measure at least up to maxValue (µA),...
static T minRange(const quint32 maxValue)
void deviceDiscovered(const QBluetoothDeviceInfo &info) override
Checks if info is the device (if any) we're looking for, and if so, create a contoller and service,...
void disconnect(int exitCode=EXIT_SUCCESS)
Disconnects the underlying Pokit device, and sets exitCode to be return to the OS once the disconnect...
virtual AbstractPokitService * getService()=0
Returns a Pokit service object for the derived command class.
The PokitDevice class simplifies Pokit device access.
QLowEnergyController * controller()
Returns a non-const pointer to the controller used to access the Pokit device.
void start(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods methods)
Starts Pokit device discovery.
Encapsulates details specific to Pokit Meter devices.
CurrentRange
Values supported by the Pokit Meter's Range attributes in *Current modes.
ResistanceRange
Values supported by the Pokit Meter's Range attributes in Resistance mode.
VoltageRange
Values supported by the Pokit Meter's Range attributes in *Voltage modes.
@ _60V
Up to 60V DC (42V AC).
Encapsulates details specific to Pokit Pro devices.
VoltageRange
Values supported by the Pokit Pro's Range attributes in *Voltage modes.
CurrentRange
Values supported by the Pokit Pro's Range attributes in *Current modes.
ResistanceRange
Values supported by the Pokit Pro's Range attributes in Resistance mode.
CapacitanceRange
Values supported by the Pokit Pro's Range attributes in Capacitance mode.
Declares the PokitDevice class.
Declares the PokitDiscoveryAgent class.
Declares the PokitMeter namespace.
Declares the PokitPro namespace.
QTPOKIT_EXPORT PokitProduct pokitProduct(const QBluetoothDeviceInfo &info)
Returns the PokitProduct corresponding the Bluetotoh device info.
PokitProduct
Pokit products known to, and supported by, the QtPokit library.
QTPOKIT_EXPORT QString toString(const PokitProduct product)
Returns product as user-friendly string.
QTPOKIT_EXPORT bool isPokitProduct(const QBluetoothDeviceInfo &info)
Returns true if info describes a Pokit device.
bool isNull() const const
QString toString() const const
QBluetoothAddress address() const const
QBluetoothUuid deviceUuid() const const
QString name() const const
void exit(int returnCode)
void disconnectFromDevice()
QLowEnergyController::Error error() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isEmpty() const const
bool isNull() const const
bool isNull() const const
QString toString() const const