51 qCDebug(d->lc).noquote() <<
tr(
"Ignoring read request; the Calibration service is write-only.");
64 static_assert(
sizeof(float) == 4,
"Pokit devices expect 32-bit floats");
68 if (!characteristic.
isValid()) {
73 qCDebug(d->lc).noquote() <<
tr(
"Writing new temperature %1 (0x%2).")
75 d->service->writeCharacteristic(characteristic, newValue);
76 return (d->service->error() != QLowEnergyService::ServiceError::CharacteristicWriteError);
111 static_assert(
sizeof(value) == 4,
"Pokit devices expect 32-bit floats");
113 qToLittleEndian<float>(value, bytes.
data());
128 Q_EMIT q->temperatureCalibrated();
132 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)
Calibrates the Pokit device's temperature to ambientTemperature.
CalibrationService(QLowEnergyController *const pokitDevice, QObject *parent=nullptr)
Constructs a new Pokit service with parent.
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.