Dokit
Internal development documentation
Loading...
Searching...
No Matches
pokitproducts.cpp File Reference

Defines the PokitProduct helper functions. More...

#include <qtpokit/pokitmeter.h>
#include <qtpokit/pokitpro.h>
#include <qtpokit/pokitproducts.h>
#include <qtpokit/statusservice.h>
#include "pokitproducts_p.h"
#include <QCoreApplication>
#include <QLoggingCategory>
Include dependency graph for pokitproducts.cpp:

Go to the source code of this file.

Classes

class  QTPOKIT_BEGIN_NAMESPACE::Private
 

Namespaces

namespace  CapacitanceRange
 Encapsulates convenience functions for working with capacitance ranges.
 
namespace  CurrentRange
 Encapsulates convenience functions for working with current ranges.
 
namespace  ResistanceRange
 Encapsulates convenience functions for working with resistance ranges.
 
namespace  VoltageRange
 Encapsulates convenience functions for working with voltage ranges.
 

Functions

static Q_LOGGING_CATEGORY (lc, "dokit.pokit.products", QtInfoMsg)
 Logging category for this file.
 
QString toString (const PokitProduct product)
 Returns product as user-friendly string.
 
bool isPokitProduct (const QBluetoothDeviceInfo &info)
 Returns true if info describes a Pokit device.
 
PokitProduct pokitProduct (const QBluetoothDeviceInfo &info)
 Returns the PokitProduct corresponding the Bluetotoh device info.
 
bool isPokitProduct (const QList< QBluetoothUuid > &serviceUuids)
 Returns true if serviceUuids contains a known Pokit Status service UUID.
 
bool isPokitProduct (const QLowEnergyController &controller)
 Returns true if controller describes a Pokit device.
 
PokitProduct pokitProduct (const QList< QBluetoothUuid > &serviceUuids)
 Returns the PokitProduct corresponding to the Bluetooth serviceUuids.
 
PokitProduct pokitProduct (const QLowEnergyController &controller)
 Returns the PokitProduct corresponding to the Bluetooth controller.
 
QString CapacitanceRange::toString (const PokitProduct product, const quint8 range)
 Returns product's capacitance range as a human-friendly string.
 
quint32 CapacitanceRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for range in nanofarads, or 0 if range is not a known value for product.
 
QString CurrentRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
quint32 CurrentRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for range in microamps, or 0 if range is not a known value for product.
 
QString ResistanceRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
quint32 ResistanceRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for range in ohms, or 0 if range is not a known value for product.
 
QString VoltageRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
quint32 VoltageRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for range in millivolts, or 0 if range is not a known value for product.
 

Detailed Description

Defines the PokitProduct helper functions.

Definition in file pokitproducts.cpp.

Function Documentation

◆ isPokitProduct() [1/3]

bool isPokitProduct ( const QBluetoothDeviceInfo & info)

Returns true if info describes a Pokit device.

Currently, this is based on whether or not info's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

Definition at line 49 of file pokitproducts.cpp.

50{
51 return isPokitProduct(info.serviceUuids());
52}
bool isPokitProduct(const QBluetoothDeviceInfo &info)
Returns true if info describes a Pokit device.
QList< QBluetoothUuid > serviceUuids(QBluetoothDeviceInfo::DataCompleteness *completeness) const const

References isPokitProduct(), and QBluetoothDeviceInfo::serviceUuids().

Referenced by DeviceCommand::deviceDiscovered(), PokitDiscoveryAgentPrivate::deviceDiscovered(), PokitDiscoveryAgentPrivate::deviceUpdated(), isPokitProduct(), and isPokitProduct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPokitProduct() [2/3]

bool isPokitProduct ( const QList< QBluetoothUuid > & serviceUuids)

Returns true if serviceUuids contains a known Pokit Status service UUID.

Currently, this is the only known way to detect a Pokit device.

Definition at line 73 of file pokitproducts.cpp.

74{
77}
bool contains(const T &value) const const
static const QBluetoothUuid pokitPro
UUID of the Pokit Pro's Pokit Status service.
static const QBluetoothUuid pokitMeter
UUID of the Pokit Meter's Pokit Status service.

References QList::contains(), StatusService::ServiceUuids::pokitMeter, and StatusService::ServiceUuids::pokitPro.

Here is the call graph for this function:

◆ isPokitProduct() [3/3]

bool isPokitProduct ( const QLowEnergyController & controller)

Returns true if controller describes a Pokit device.

Currently, this is based on whether or not controller's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 88 of file pokitproducts.cpp.

89{
90 return isPokitProduct(controller.services());
91}
QList< QBluetoothUuid > services() const const

References isPokitProduct(), and QLowEnergyController::services().

Here is the call graph for this function:

◆ pokitProduct() [1/3]

PokitProduct pokitProduct ( const QBluetoothDeviceInfo & info)

Returns the PokitProduct corresponding the Bluetotoh device info.

If info is not a Pokit device, then result is undefined.

See also
isPokitProduct

Definition at line 61 of file pokitproducts.cpp.

62{
63 return pokitProduct(info.serviceUuids());
64}
PokitProduct pokitProduct(const QBluetoothDeviceInfo &info)
Returns the PokitProduct corresponding the Bluetotoh device info.

References pokitProduct(), and QBluetoothDeviceInfo::serviceUuids().

Referenced by DeviceCommand::deviceDiscovered(), pokitProduct(), and pokitProduct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pokitProduct() [2/3]

PokitProduct pokitProduct ( const QList< QBluetoothUuid > & serviceUuids)

Returns the PokitProduct corresponding to the Bluetooth serviceUuids.

Currently, this is based on whether or not servceUuids includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 101 of file pokitproducts.cpp.

102{
105 } else if (serviceUuids.contains(StatusService::ServiceUuids::pokitPro)) {
107 } else {
108 qCWarning(lc).noquote() << Private::tr("Device is not a Pokit product");
109 qCDebug(lc).noquote() << "Service UUIDs:" << serviceUuids;
110 return PokitProduct::PokitMeter; // Need to fallback to something; Pokit Meter is just the lowest product.
111 }
112}
@ PokitPro
Pokit Pro.
@ PokitMeter
Pokit Meter.

References QList::contains(), PokitMeter, StatusService::ServiceUuids::pokitMeter, PokitPro, and StatusService::ServiceUuids::pokitPro.

Here is the call graph for this function:

◆ pokitProduct() [3/3]

PokitProduct pokitProduct ( const QLowEnergyController & controller)

Returns the PokitProduct corresponding to the Bluetooth controller.

Currently, this is based on whether or not controller's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 122 of file pokitproducts.cpp.

123{
124 return pokitProduct(controller.services());
125}

References pokitProduct(), and QLowEnergyController::services().

Here is the call graph for this function:

◆ toString()

QString toString ( const PokitProduct product)

Returns product as user-friendly string.

Definition at line 33 of file pokitproducts.cpp.

34{
35 switch (product) {
36 case PokitProduct::PokitMeter: return QStringLiteral("Pokit Meter");
37 case PokitProduct::PokitPro: return QStringLiteral("Pokit Pro");
38 }
39 qCWarning(lc).noquote() << Private::tr("Unknown PokitProduct value: %1").arg((int)product);
40 return QString();
41}

References QString::arg(), PokitMeter, and PokitPro.

Referenced by AbstractPokitServicePrivate::createServiceObject(), and DeviceCommand::deviceDiscovered().

Here is the call graph for this function:
Here is the caller graph for this function: