21#include <QMutexLocker>
101 return d->controller;
105#define QTPOKIT_INTERNAL_GET_SERVICE(typeName, varName) \
107 const QMutexLocker scopedLock(&d->varName##Mutex);\
108 if (d->varName == nullptr) { \
109 d->varName = new typeName(d->controller); \
186#undef QTPOKIT_INTERNAL_GET_SERVICE
207 { QBluetoothUuid::ServiceClassUuid::GenericAccess,
209 { QBluetoothUuid::ServiceClassUuid::GenericAttribute,
211 {
QBluetoothUuid(u
"1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0"_s),
tr(
"OTA Firmware Update") },
213 return hash.
value(uuid);
261 {
QBluetoothUuid(u
"f7bf3564-fb6d-4e53-88a4-5e37e0326063"_s),
tr(
"OTA Control") },
262 {
QBluetoothUuid(u
"984227f3-34fc-4045-a5d0-2c581f81a153"_s),
tr(
"OTA Data Transfer") },
264 return hash.
value(uuid);
298 qCDebug(lc).noquote() <<
tr(
"Controller already set to:") << newController;
303 qCDebug(lc).noquote() <<
tr(
"Disconnecting signals from previous controller:")
308 qCDebug(lc).noquote() <<
tr(
"Setting new controller:") << newController;
310 if (!newController) {
314 qCDebug(lc).noquote() <<
tr(R
"(Set new controller "%1" (%2) at (%3).)").arg(
332 #
if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
335 &QLowEnergyController::errorOccurred,
353 qCCritical(lc).noquote() <<
tr(
"PokitDevicePrivate::connected slot invoked without a controller.");
356 qCDebug(lc).noquote() <<
tr(R
"(Connected to "%1" (%2) at (%3).)").arg(
366 qCDebug(lc).noquote() <<
tr(
"Connection updated:") << newParameters.
latency()
376 qCDebug(lc).noquote() <<
tr(
"Device disconnected.");
384 qCDebug(lc).noquote() <<
tr(
"Service discovery finished.");
392 qCDebug(lc).noquote() <<
tr(
"Controller error:") << newError;
400 qCDebug(lc).noquote() <<
tr(R
"(Service discovered: %1 "%2")")
409 qCDebug(lc).noquote() <<
tr(
"State changed to:") << state;
Declares the CalibrationService class.
The CalibrationService class accesses the Calibrartion service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the Calibration service.
The DataLoggerService class accesses the Data Logger service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the "DataLogger" service.
The DeviceInfoService class accesses the Device Info service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the "Device Info" service.
The DsoService class accesses the DSO (Digital Storage Oscilloscope) service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the "DSO" service.
The MultimeterService class accesses the Multimeter service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the Multimeter service.
The PokitDevicePrivate class provides private implementation for PokitDevice.
PokitDevicePrivate(PokitDevice *const q)
Constructs a new PokitDevicePrivate object with public implementation q.
void connected() const
Handle connected signals.
void disconnected() const
Handle disconnected signals.
void errorOccurred(QLowEnergyController::Error newError) const
Handle error signals.
void stateChanged(QLowEnergyController::ControllerState state) const
Handle stateChanged signals.
void setController(QLowEnergyController *newController)
Sets newController to be used for accessing Pokit devices.
void connectionUpdated(const QLowEnergyConnectionParameters &newParameters) const
Handle connectionUpdated signals.
QLowEnergyController * controller
BLE controller for accessing the Pokit device.
void discoveryFinished() const
Handle discoveryFinished signals.
PokitDevice * q_ptr
Internal q-pointer.
void serviceDiscovered(const QBluetoothUuid &newService) const
Handle serviceDiscovered signals.
The PokitDevice class simplifies Pokit device access.
static QString charcteristicToString(const QBluetoothUuid &uuid)
Returns a human-readable name for the uuid characteristic, or a null QString if unknown.
DeviceInfoService * deviceInformation()
Returns a pointer to DeviceInformationService instance that uses this device's controller for access.
QLowEnergyController * controller()
Returns a non-const pointer to the controller used to access the Pokit device.
virtual ~PokitDevice()
Destroys this PokitDevice object.
DsoService * dso()
Returns a pointer to DsoService instance that uses this device's controller for access.
PokitDevice(const QBluetoothDeviceInfo &deviceInfo, QObject *parent=nullptr)
Constructs a new Pokit device controller wrapper for deviceInfo, with parent.
PokitDevicePrivate * d_ptr
Internal d-pointer.
DataLoggerService * dataLogger()
Returns a pointer to a DataLoggerService instance that uses this device's controller for access.
MultimeterService * multimeter()
Returns a pointer to MultimeterService instance that uses this device's controller for access.
CalibrationService * calibration()
Returns a pointer to a CalibrationService instance that uses this device's controller for access.
static QString serviceToString(const QBluetoothUuid &uuid)
Returns a human-readable name for the uuid service, or a null QString if unknown.
StatusService * status()
Returns a pointer to StatusService instance that uses this device's controller for access.
The StatusService class accesses the Pokit Status service of Pokit devices.
Declares the DataLoggerService class.
Declares the DeviceInfoService class.
Declares the DsoService class.
Declares the MultimeterService class.
Declares the PokitDevice class.
Declares the PokitDevicePrivate class.
QString characteristicToString(QBluetoothUuid::CharacteristicType uuid)
QString serviceClassToString(QBluetoothUuid::ServiceClassUuid uuid)
const T value(const Key &key) const const
int latency() const const
double maximumInterval() const const
double minimumInterval() const const
int supervisionTimeout() const const
void connectionUpdated(const QLowEnergyConnectionParameters &newParameters)
QLowEnergyController * createCentral(const QBluetoothDeviceInfo &remoteDevice, QObject *parent)
QLowEnergyController::Error error() const const
void serviceDiscovered(const QBluetoothUuid &newService)
void stateChanged(QLowEnergyController::ControllerState state)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QObject * parent() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
#define QTPOKIT_BEGIN_NAMESPACE
Macro for starting the QtPokit library's top-most namespace (if one is defined).
#define QTPOKIT_END_NAMESPACE
Macro for ending the QtPokit library's top-most namespace (if one is defined).
QString toString() const const
Declares the StatusService class.
Declares the DOKIT_USE_STRINGLITERALS macro, and related functions.
#define DOKIT_USE_STRINGLITERALS
Internal macro for using either official Qt string literals (added in Qt 6.4), or our own equivalent ...
static const QBluetoothUuid setParam
static const QBluetoothUuid getParam
static const QBluetoothUuid temperature
UUID of the Calibration service's Temperature characteristic.
static const QBluetoothUuid metadata
UUID of the DataLogger service's Metadata characteristic.
static const QBluetoothUuid settings
UUID of the DataLogger service's Settings characteristic.
static const QBluetoothUuid reading
UUID of the DataLogger service's Reading characteristic.
static const QBluetoothUuid manufacturerName
UUID of the Device Info service's Manufacturer Name String characteristic.
static const QBluetoothUuid hardwareRevision
UUID of the Device Info service's Hardware Revision String characteristic.
static const QBluetoothUuid softwareRevision
UUID of the Device Info service's Software Revision String characteristic.
static const QBluetoothUuid serialNumber
UUID of the Device Info service's Serial Number String characteristic.
static const QBluetoothUuid firmwareRevision
UUID of the Device Info service's Firmware Revision String characteristic.
static const QBluetoothUuid modelNumber
UUID of the Device Info service's Model Number String characteristic.
static const QBluetoothUuid metadata
UUID of the DSO service's Metadata characteristic.
static const QBluetoothUuid reading
UUID of the DSO service's Reading characteristic.
static const QBluetoothUuid settings
UUID of the DSO service's Settings characteristic.
static const QBluetoothUuid reading
UUID of the Multimeter service's Reading characteristic.
static const QBluetoothUuid settings
UUID of the Multimeter service's Settings characteristic.
static const QBluetoothUuid name
UUID of the Pokit Status service's Device Name characteristic.
static const QBluetoothUuid torch
UUID of the Pokit Status service's (undocumented) Torch characteristic.
static const QBluetoothUuid deviceCharacteristics
UUID of the Pokit Status service's Device Characteristics characteristic.
static const QBluetoothUuid buttonPress
UUID of the Pokit Status service's (undocumented) Button Press characteristic.
static const QBluetoothUuid flashLed
UUID of the Pokit Status service's Flash LED characteristic.
static const QBluetoothUuid status
UUID of the Pokit Status service's Status characteristic.
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.