21#include <QMutexLocker>
102#define QTPOKIT_INTERNAL_GET_SERVICE(typeName, varName) \
104 const QMutexLocker scopedLock(&d->varName##Mutex);\
105 if (d->varName == nullptr) { \
106 d->varName = new typeName(d->controller); \
195#undef QTPOKIT_INTERNAL_GET_SERVICE
217 { QBluetoothUuid::ServiceClassUuid::GenericAttribute,
219 {
QBluetoothUuid(QStringLiteral(
"1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0")),
tr(
"OTA Firmware Update") },
221 return hash.value(uuid);
274 {
QBluetoothUuid(QStringLiteral(
"f7bf3564-fb6d-4e53-88a4-5e37e0326063")),
tr(
"OTA Control") },
275 {
QBluetoothUuid(QStringLiteral(
"984227f3-34fc-4045-a5d0-2c581f81a153")),
tr(
"OTA Data Transfer") },
277 return hash.value(uuid);
311 qCDebug(lc).noquote() <<
tr(
"Controller already set to:") << newController;
316 qCDebug(lc).noquote() <<
tr(
"Disconnecting signals from previous controller:")
321 qCDebug(lc).noquote() <<
tr(
"Setting new controller:") << newController;
323 if (!newController) {
327 qCDebug(lc).noquote() <<
tr(R
"(Set new controller "%1" (%2) at (%3).)").arg(
345 #
if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
348 &QLowEnergyController::errorOccurred,
366 qCCritical(lc).noquote() <<
tr(
"PokitDevicePrivate::connected slot invoked without a controller.");
369 qCDebug(lc).noquote() <<
tr(R
"(Connected to "%1" (%2) at (%3).)").arg(
379 qCDebug(lc).noquote() <<
tr(
"Connection updated:") << newParameters.
latency()
389 qCDebug(lc).noquote() <<
tr(
"Device disconnected.");
397 qCDebug(lc).noquote() <<
tr(
"Service discovery finished.");
405 qCDebug(lc).noquote() <<
tr(
"Controller error:") << newError;
413 qCDebug(lc).noquote() <<
tr(R
"(Service discovered: %1 "%2")")
422 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 GenericAccessService class accesses the Generic Access service of Pokit devices.
static const QBluetoothUuid serviceUuid
UUID of the Generic Access 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.
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.
GenericAccessService * genericAccess()
Returns a pointer to GenericAccessService 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 unknonw.
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 GenericAccessService class.
Declares the MultimeterService class.
Declares the PokitDevice class.
Declares the PokitDevicePrivate class.
QString toString() const const
QString characteristicToString(QBluetoothUuid::CharacteristicType uuid)
QString serviceClassToString(QBluetoothUuid::ServiceClassUuid uuid)
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
QBluetoothAddress remoteAddress() const const
QBluetoothUuid remoteDeviceUuid() const const
QString remoteName() 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)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString toString() const const
Declares the StatusService class.
static const QBluetoothUuid setParam
static const QBluetoothUuid getParam
static const QBluetoothUuid temperature
UUID of the Calibration service's Temperature characterstic.
static const QBluetoothUuid metadata
UUID of the DataLogger service's Metadata characterstic.
static const QBluetoothUuid settings
UUID of the DataLogger service's Settings characterstic.
static const QBluetoothUuid reading
UUID of the DataLogger service's Reading characterstic.
static const QBluetoothUuid manufacturerName
UUID of the Device Info service's Manufacturer Name String characterstic.
static const QBluetoothUuid hardwareRevision
UUID of the Device Info service's Hardware Revision String characterstic.
static const QBluetoothUuid softwareRevision
UUID of the Device Info service's Software Revision String characterstic.
static const QBluetoothUuid serialNumber
UUID of the Device Info service's Serial Number String characterstic.
static const QBluetoothUuid firmwareRevision
UUID of the Device Info service's Firmware Revision String characterstic.
static const QBluetoothUuid modelNumber
UUID of the Device Info service's Model Number String characterstic.
static const QBluetoothUuid metadata
UUID of the DSO service's Metadata characterstic.
static const QBluetoothUuid reading
UUID of the DSO service's Reading characterstic.
static const QBluetoothUuid settings
UUID of the DSO service's Settings characterstic.
static const QBluetoothUuid deviceName
UUID of the Generic Access service's Device Name characterstic.
static const QBluetoothUuid appearance
UUID of the Generic Access service's Appearance characterstic.
static const QBluetoothUuid reading
UUID of the Multimeter service's Reading characterstic.
static const QBluetoothUuid settings
UUID of the Multimeter service's Settings characterstic.
static const QBluetoothUuid name
UUID of the Pokit Status service's Device Name characterstic.
static const QBluetoothUuid torch
UUID of the Pokit Status service's (undocumented) Torch characterstic.
static const QBluetoothUuid deviceCharacteristics
UUID of the Pokit Status service's Device Characteristics characterstic.
static const QBluetoothUuid buttonPress
UUID of the Pokit Status service's (undocumented) Button Press characterstic.
static const QBluetoothUuid flashLed
UUID of the Pokit Status service's Flash LED characterstic.
static const QBluetoothUuid status
UUID of the Pokit Status service's Status characterstic.
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.