59 qCDebug(d->lc).noquote() <<
tr(
"Ignoring read request; the Calibration service is write-only.");
72 static_assert(
sizeof(float) == 4,
"Pokit devices expect 32-bit floats");
76 if (!characteristic.
isValid()) {
81 qCDebug(d->lc).noquote() <<
tr(
"Writing new temperature %1 (0x%2).")
83 d->service->writeCharacteristic(characteristic, newValue);
84 return (d->service->error() != QLowEnergyService::ServiceError::CharacteristicWriteError);
119 static_assert(
sizeof(value) == 4,
"Pokit devices expect 32-bit floats");
121 qToLittleEndian<float>(value, bytes.
data());
136 Q_EMIT q->temperatureCalibrated();
140 qCWarning(lc).noquote() <<
tr(
"Unknown characteristic written for Calibration service")
Declares the CalibrationService class.
Declares the CalibrationServicePrivate class.
The AbstractPokitServicePrivate class provides private implementation for AbstractPokitService.
QBluetoothUuid serviceUuid
UUIDs for service.
virtual void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
Handles QLowEnergyService::characteristicWritten events.
The AbstractPokitService class provides a common base for Pokit services classes.
The CalibrationServicePrivate class provides private implementation for CalibrationService.
CalibrationServicePrivate(QLowEnergyController *controller, CalibrationService *const q)
static QByteArray encodeTemperature(const float value)
Returns value in a format Pokit devices expect.
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue) override
Implements AbstractPokitServicePrivate::characteristicWritten to parse newValue, then emit a speciali...
The CalibrationService class accesses the Calibrartion service of Pokit devices.
bool calibrateTemperature(const float ambientTemperature)
Set's the Pokit device's name to name.
CalibrationService(QLowEnergyController *const pokitDevice, QObject *parent=nullptr)
Constructs a new Pokit service with parent.
~CalibrationService() override
Destroys this CalibrationService object.
bool readCharacteristics() override
Read all characteristics.
QByteArray toHex() const const
bool isValid() const const
QString name() const const
QBluetoothUuid uuid() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
static const QBluetoothUuid temperature
UUID of the Calibration service's Temperature characterstic.