36 : AbstractPokitService(d,
parent)
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.
QBluetoothUuid serviceUuid
UUIDs for service.
AbstractPokitServicePrivate(const QBluetoothUuid &serviceUuid, QLowEnergyController *controller, AbstractPokitService *const q)
virtual void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
Handles QLowEnergyService::characteristicWritten events.
QLowEnergyController * controller
BLE controller to fetch the service from.
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
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
static const QBluetoothUuid temperature
UUID of the Calibration service's Temperature characterstic.