109 : std::numeric_limits<quint16>::max();
139 if (!characteristic.
isValid()) {
144 if (value.
length() > 11) {
145 qCWarning(d->lc).noquote() <<
tr(R
"(Device name "%1" is too long (%2 > 11 bytes): 0x%3)")
150 d->service->writeCharacteristic(characteristic, value);
151 return (d->service->error() != QLowEnergyService::ServiceError::CharacteristicWriteError);
204 return std::numeric_limits<quint16>::max();
206 const quint16 appearance = qFromLittleEndian<quint16>(value.
constData());
207 qCDebug(lc).noquote() <<
tr(
"Appearance: %1.").
arg(appearance);
228 qCDebug(lc).noquote() <<
tr(R
"(Device name: "%1")").arg(deviceName);
229 Q_EMIT q->deviceNameRead(deviceName);
233 qCWarning(lc).noquote() <<
tr(
"Unknown characteristic read for Generic Access service")
248 qCWarning(lc).noquote() <<
tr(
"Appearance haracteristic is read-only, but somehow written")
254 Q_EMIT q->deviceNameWritten();
258 qCWarning(lc).noquote() <<
tr(
"Unknown characteristic written for Generic Access service")
The AbstractPokitServicePrivate class provides private implementation for AbstractPokitService.
QBluetoothUuid serviceUuid
UUIDs for service.
virtual void characteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
Handles QLowEnergyService::characteristicRead events.
virtual void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
Handles QLowEnergyService::characteristicWritten events.
static bool checkSize(const QString &label, const QByteArray &data, const int minSize, const int maxSize=-1, const bool failOnMax=false)
Returns false if data is smaller than minSize, otherwise returns failOnMax if data is bigger than max...
The AbstractPokitService class provides a common base for Pokit services classes.
The GenericAccessServicePrivate class provides private implementation for GenericAccessService.
GenericAccessServicePrivate(QLowEnergyController *controller, GenericAccessService *const q)
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue) override
Implements AbstractPokitServicePrivate::characteristicWritten to parse newValue, then emit a speciali...
void characteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value) override
Implements AbstractPokitServicePrivate::characteristicRead to parse value, then emit a specialised si...
static quint16 parseAppearance(const QByteArray &value)
Parses the Appearance value.
The GenericAccessService class accesses the Generic Access service of Pokit devices.
quint16 appearance() const
Returns the most recent value of the Generic Access services's Appearance characteristic.
bool readDeviceNameCharacteristic()
Read the Generic Access service's Device Name characteristic.
bool readAppearanceCharacteristic()
Read the Generic Access service's Appearance characteristic.
GenericAccessService(QLowEnergyController *const pokitDevice, QObject *parent=nullptr)
Constructs a new Pokit service with parent.
bool setDeviceName(const QString &name)
Set's the Pokit device's name to name.
QString deviceName() const
Returns the most recent value of the Generic Access services's Device Name characteristic.
bool readCharacteristics() override
Read all characteristics.
~GenericAccessService() override
Destroys this GenericAccessService object.
Declares the GenericAccessService class.
Declares the GenericAccessServicePrivate class.
const char * constData() const const
QByteArray toHex() const const
bool isValid() const const
QString name() const const
QBluetoothUuid uuid() const const
QByteArray value() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromUtf8(const char *str, int size)
QByteArray toUtf8() const const
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.