Dokit
Internal development documentation
|
The AbstractPokitServicePrivate class provides private implementation for AbstractPokitService. More...
Public Member Functions | |
AbstractPokitServicePrivate (const QBluetoothUuid &serviceUuid, QLowEnergyController *controller, AbstractPokitService *const q) | |
bool | createServiceObject () |
Creates an internal service object from the internal controller. | |
QLowEnergyCharacteristic | getCharacteristic (const QBluetoothUuid &uuid) const |
Get uuid characteristc from the underlying service. | |
bool | readCharacteristic (const QBluetoothUuid &uuid) |
Read the uuid characteristic. | |
bool | enableCharacteristicNotificatons (const QBluetoothUuid &uuid) |
Enables client (Pokit device) side notification for characteristic uuid. | |
bool | disableCharacteristicNotificatons (const QBluetoothUuid &uuid) |
Disables client (Pokit device) side notification for characteristic uuid. | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Static Public Member Functions | |
static | Q_LOGGING_CATEGORY (lc, "pokit.ble.service", QtInfoMsg) |
Logging category. | |
static bool | checkSize (const QString &label, const QByteArray &data, const int minSize, const int maxSize=-1, const bool failOnMax=false) |
Returns false if data is smaller than minSize, otherwise returns failOnMax if data is bigger than maxSize, otherwise returns true . | |
static QString | toHexString (const QByteArray &data, const int maxSize=20) |
Returns up to maxSize bytes of data as a human readable hexadecimal string. | |
Static Public Member Functions inherited from QObject | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Public Attributes | |
bool | autoDiscover { true } |
Whether autodiscovery is enabled or not. | |
QLowEnergyController * | controller { nullptr } |
BLE controller to fetch the service from. | |
std::optional< PokitProduct > | pokitProduct |
The Pokit product controller is connected to. | |
QLowEnergyService * | service { nullptr } |
BLE service to read/write characteristics. | |
QBluetoothUuid | serviceUuid |
UUIDs for service. | |
Public Attributes inherited from QObject | |
typedef | QObjectList |
Protected Attributes | |
AbstractPokitService * | q_ptr |
Internal q-pointer. | |
Friends | |
class | TestAbstractPokitService |
Additional Inherited Members | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
Properties inherited from QObject | |
objectName | |
The AbstractPokitServicePrivate class provides private implementation for AbstractPokitService.
Definition at line 27 of file abstractpokitservice_p.h.
AbstractPokitServicePrivate::AbstractPokitServicePrivate | ( | const QBluetoothUuid & | serviceUuid, |
QLowEnergyController * | controller, | ||
AbstractPokitService *const | q ) |
Constructs a new AbstractPokitServicePrivate object with public implementation q.
Note, typically the serviceUuid should be set validly, however, in the rare case that a service's UUID can vary (ie the Status Service), serviceUuid may be set to a null
QBluetoothUuid here, and updated when the correct service UUID is known.
Definition at line 168 of file abstractpokitservice.cpp.
References QObject::connect(), connected(), QLowEnergyController::connected(), controller, createServiceObject(), discoveryFinished(), QLowEnergyController::discoveryFinished(), serviceDiscovered(), and QLowEnergyController::serviceDiscovered().
|
protectedvirtualslot |
Handles QLowEnergyService::characteristicChanged
events.
This base implementation simply debug logs the event.
If derived classes support characteristics with client-side notification (ie Notify, as opposed to Read or Write operations), they should implement this function to handle the successful reads of characteristic, typically by parsing value, then emitting a speciailised signal.
Reimplemented in DataLoggerServicePrivate, DsoServicePrivate, and MultimeterServicePrivate.
Definition at line 591 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), QByteArray::size(), toHexString(), QUuid::toString(), QObject::tr(), and QLowEnergyCharacteristic::uuid().
Referenced by DataLoggerServicePrivate::characteristicChanged(), DsoServicePrivate::characteristicChanged(), MultimeterServicePrivate::characteristicChanged(), and createServiceObject().
|
protectedvirtualslot |
Handles QLowEnergyService::characteristicRead
events.
This base implementation simply debug logs the event.
Derived classes should implement this function to handle the successful reads of characteristic, typically by parsing value, then emitting a speciailised signal.
Reimplemented in DataLoggerServicePrivate, DeviceInfoServicePrivate, DsoServicePrivate, MultimeterServicePrivate, and StatusServicePrivate.
Definition at line 562 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), QByteArray::size(), toHexString(), QUuid::toString(), QObject::tr(), and QLowEnergyCharacteristic::uuid().
Referenced by DataLoggerServicePrivate::characteristicRead(), DeviceInfoServicePrivate::characteristicRead(), DsoServicePrivate::characteristicRead(), MultimeterServicePrivate::characteristicRead(), StatusServicePrivate::characteristicRead(), and createServiceObject().
|
protectedvirtualslot |
Handles QLowEnergyService::characteristicWritten
events.
This base implementation simply debug logs the event.
Derived classes should implement this function to handle the successful writes of characteristic, typically by parsing newValue, then emitting a speciailised signal.
Reimplemented in CalibrationServicePrivate, DataLoggerServicePrivate, DsoServicePrivate, MultimeterServicePrivate, and StatusServicePrivate.
Definition at line 576 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), QByteArray::size(), toHexString(), QUuid::toString(), QObject::tr(), and QLowEnergyCharacteristic::uuid().
Referenced by CalibrationServicePrivate::characteristicWritten(), DataLoggerServicePrivate::characteristicWritten(), DsoServicePrivate::characteristicWritten(), MultimeterServicePrivate::characteristicWritten(), StatusServicePrivate::characteristicWritten(), and createServiceObject().
|
static |
Returns false
if data is smaller than minSize, otherwise returns failOnMax if data is bigger than maxSize, otherwise returns true
.
A warning is logged if either minSize or maxSize is violated, regardless of the returned value; ie this funcion can be used to simply warn if data is too big, or it can be used to failed (return false
) in that case.
Definition at line 400 of file abstractpokitservice.cpp.
References QString::arg(), QByteArray::mid(), QByteArray::size(), toHexString(), and QObject::tr().
Referenced by StatusServicePrivate::characteristicRead(), StatusServicePrivate::parseButtonPress(), StatusServicePrivate::parseDeviceCharacteristics(), DataLoggerServicePrivate::parseMetadata(), DsoServicePrivate::parseMetadata(), MultimeterServicePrivate::parseReading(), StatusServicePrivate::parseStatus(), and StatusServicePrivate::parseTorchStatus().
|
protectedslot |
Handles QLowEnergyController::connected
events.
If autoDiscover
is enabled, this will begin service discovery on the newly connected contoller.
Definition at line 441 of file abstractpokitservice.cpp.
References QString::arg(), autoDiscover, controller, QLowEnergyController::discoverServices(), QLowEnergyController::remoteAddress(), QLowEnergyController::remoteDeviceUuid(), QLowEnergyController::remoteName(), QObject::sender(), QBluetoothAddress::toString(), QUuid::toString(), and QObject::tr().
Referenced by AbstractPokitServicePrivate().
bool AbstractPokitServicePrivate::createServiceObject | ( | ) |
Creates an internal service object from the internal controller.
Any existing service object will not be replaced.
Returns true
if a service was created successfully, either now, or sometime previously.
Definition at line 193 of file abstractpokitservice.cpp.
References QString::arg(), autoDiscover, characteristicChanged(), QLowEnergyService::characteristicChanged(), characteristicRead(), QLowEnergyService::characteristicRead(), characteristicWritten(), QLowEnergyService::characteristicWritten(), QObject::connect(), controller, QLowEnergyController::createServiceObject(), QLowEnergyService::descriptorRead(), QLowEnergyService::descriptorWritten(), QLowEnergyService::discoverDetails(), QLowEnergyService::error(), errorOccurred(), QUuid::isNull(), QLowEnergyDescriptor::name(), pokitProduct, service, serviceUuid, stateChanged(), QLowEnergyService::stateChanged(), QUuid::toString(), toString(), QObject::tr(), and QLowEnergyDescriptor::uuid().
Referenced by AbstractPokitServicePrivate(), discoveryFinished(), and serviceDiscovered().
bool AbstractPokitServicePrivate::disableCharacteristicNotificatons | ( | const QBluetoothUuid & | uuid | ) |
Disables client (Pokit device) side notification for characteristic uuid.
Returns true
if the notication disable request was successfully queued, false
otherwise.
Definition at line 365 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), QLowEnergyCharacteristic::descriptor(), QByteArray::fromHex(), getCharacteristic(), QLowEnergyCharacteristic::isValid(), QLowEnergyDescriptor::isValid(), service, QUuid::toString(), QObject::tr(), and QLowEnergyService::writeDescriptor().
|
protectedslot |
Handles QLowEnergyController::discoveryFinished
events.
As this event indicates that the conroller has finished discovering services, this function will invoke createServiceObject() to create the internal service object (if not already created).
Definition at line 462 of file abstractpokitservice.cpp.
References QString::arg(), controller, createServiceObject(), QObject::Q_EMIT(), QLowEnergyController::remoteAddress(), QLowEnergyController::remoteDeviceUuid(), QLowEnergyController::remoteName(), QObject::sender(), QBluetoothAddress::toString(), QUuid::toString(), and QObject::tr().
Referenced by AbstractPokitServicePrivate().
bool AbstractPokitServicePrivate::enableCharacteristicNotificatons | ( | const QBluetoothUuid & | uuid | ) |
Enables client (Pokit device) side notification for characteristic uuid.
Returns true
if the notication enable request was successfully queued, false
otherwise.
Definition at line 330 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), QLowEnergyCharacteristic::descriptor(), QByteArray::fromHex(), getCharacteristic(), QLowEnergyCharacteristic::isValid(), QLowEnergyDescriptor::isValid(), service, QUuid::toString(), QObject::tr(), and QLowEnergyService::writeDescriptor().
|
protectedslot |
Handles QLowEnergyController::errorOccurred
events.
This function simply re-emits newError as AbstractPokitService::serviceErrorOccurred.
Definition at line 485 of file abstractpokitservice.cpp.
References QObject::Q_EMIT(), and QObject::tr().
Referenced by createServiceObject().
QLowEnergyCharacteristic AbstractPokitServicePrivate::getCharacteristic | ( | const QBluetoothUuid & | uuid | ) | const |
Get uuid characteristc from the underlying service.
This helper function is equivalent to
except that it performs some sanity checks, such as checking the service object pointer has been assigned first, and also logs failures in a consistent manner.
uuid |
Definition at line 265 of file abstractpokitservice.cpp.
References QString::arg(), QLowEnergyService::characteristic(), PokitDevice::charcteristicToString(), QLowEnergyCharacteristic::isValid(), service, PokitDevice::serviceToString(), QLowEnergyService::serviceUuid(), QLowEnergyService::state(), QUuid::toString(), and QObject::tr().
Referenced by disableCharacteristicNotificatons(), enableCharacteristicNotificatons(), and readCharacteristic().
bool AbstractPokitServicePrivate::readCharacteristic | ( | const QBluetoothUuid & | uuid | ) |
Read the uuid characteristic.
If succesful, the QLowEnergyService::characteristicRead
signal will be emitted by the internal service object. For convenience, derived classes should implement the characteristicRead() virtual function to handle the read value.
Returns true
if the characteristic read request was successfully queued, false
otherwise.
Definition at line 310 of file abstractpokitservice.cpp.
References QString::arg(), PokitDevice::charcteristicToString(), getCharacteristic(), QLowEnergyCharacteristic::isValid(), QLowEnergyService::readCharacteristic(), service, QUuid::toString(), and QObject::tr().
|
protectedvirtualslot |
Handles QLowEnergyController::serviceDiscovered
events.
If the discovered service is the one this (or rather the derived) class wraps, then createServiceObject() will be invoked immediately (otherwise it will be invoked after full service discovery has completed, ie in discoveryFinished()).
Reimplemented in StatusServicePrivate.
Definition at line 499 of file abstractpokitservice.cpp.
References createServiceObject(), service, serviceUuid, and QObject::tr().
Referenced by AbstractPokitServicePrivate(), and StatusServicePrivate::serviceDiscovered().
|
protectedslot |
Handles QLowEnergyController::stateChanged
events.
If newState indicates that service details have now been discovered, then AbstractPokitService::serviceDetailsDiscovered will be emitted.
Definition at line 515 of file abstractpokitservice.cpp.
References QString::arg(), QLowEnergyService::characteristics(), PokitDevice::charcteristicToString(), QStringList::join(), QObject::Q_EMIT(), service, and QObject::tr().
Referenced by createServiceObject().
|
static |
Returns up to maxSize bytes of data as a human readable hexadecimal string.
If data exceeds maxSize, then data is elided in the middle. For example:
Definition at line 425 of file abstractpokitservice.cpp.
References QString::arg(), QString::fromLatin1(), QByteArray::left(), QByteArray::right(), QByteArray::size(), and QByteArray::toHex().
Referenced by characteristicChanged(), characteristicRead(), characteristicWritten(), checkSize(), DataLoggerServicePrivate::parseMetadata(), DataLoggerServicePrivate::parseSamples(), and DsoServicePrivate::parseSamples().
|
friend |
Definition at line 74 of file abstractpokitservice_p.h.
bool AbstractPokitServicePrivate::autoDiscover { true } |
Whether autodiscovery is enabled or not.
Definition at line 34 of file abstractpokitservice_p.h.
Referenced by connected(), and createServiceObject().
QLowEnergyController* AbstractPokitServicePrivate::controller { nullptr } |
BLE controller to fetch the service from.
Definition at line 35 of file abstractpokitservice_p.h.
Referenced by AbstractPokitServicePrivate(), connected(), createServiceObject(), and discoveryFinished().
std::optional<PokitProduct> AbstractPokitServicePrivate::pokitProduct |
The Pokit product controller is connected to.
Definition at line 36 of file abstractpokitservice_p.h.
Referenced by createServiceObject().
|
protected |
Internal q-pointer.
Definition at line 55 of file abstractpokitservice_p.h.
QLowEnergyService* AbstractPokitServicePrivate::service { nullptr } |
BLE service to read/write characteristics.
Definition at line 37 of file abstractpokitservice_p.h.
Referenced by createServiceObject(), disableCharacteristicNotificatons(), enableCharacteristicNotificatons(), getCharacteristic(), readCharacteristic(), serviceDiscovered(), and stateChanged().
QBluetoothUuid AbstractPokitServicePrivate::serviceUuid |
UUIDs for service.
Definition at line 38 of file abstractpokitservice_p.h.
Referenced by DataLoggerServicePrivate::characteristicChanged(), DsoServicePrivate::characteristicChanged(), MultimeterServicePrivate::characteristicChanged(), DataLoggerServicePrivate::characteristicRead(), DeviceInfoServicePrivate::characteristicRead(), DsoServicePrivate::characteristicRead(), MultimeterServicePrivate::characteristicRead(), StatusServicePrivate::characteristicRead(), CalibrationServicePrivate::characteristicWritten(), DataLoggerServicePrivate::characteristicWritten(), DsoServicePrivate::characteristicWritten(), MultimeterServicePrivate::characteristicWritten(), StatusServicePrivate::characteristicWritten(), createServiceObject(), serviceDiscovered(), and StatusServicePrivate::serviceDiscovered().