Dokit
Native Qt library for Pokit devices
Loading...
Searching...
No Matches
genericaccessservice.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2023 Paul Colby <git@colby.id.au>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4/*!
5 * \file
6 * Declares the GenericAccessService class.
7 */
8
9#ifndef QTPOKIT_GENERICACCESSSERVICE_H
10#define QTPOKIT_GENERICACCESSSERVICE_H
11
13
14#include <QBluetoothAddress>
15#include <QBluetoothUuid>
16#include <QVersionNumber>
17
18QTPOKIT_BEGIN_NAMESPACE
19
20class GenericAccessServicePrivate;
21
22class QTPOKIT_EXPORT GenericAccessService : public AbstractPokitService
23{
24 Q_OBJECT
25
26public:
27 /// UUID of the `Generic Access` service.
28 static inline const QBluetoothUuid serviceUuid { QBluetoothUuid::ServiceClassUuid::GenericAccess };
29
30 /// Characteristics available via the `Generic Access` service.
31 struct QTPOKIT_EXPORT CharacteristicUuids {
32 /// UUID of the `Generic Access` service's `Device Name` characterstic.
33 static inline const QBluetoothUuid deviceName { QBluetoothUuid::CharacteristicType::DeviceName };
34
35 /// UUID of the `Generic Access` service's `Appearance` characterstic.
36 static inline const QBluetoothUuid appearance { QBluetoothUuid::CharacteristicType::Appearance };
37 };
38
39 GenericAccessService(QLowEnergyController * const pokitDevice, QObject * parent = nullptr);
40 ~GenericAccessService() override;
41
42 bool readCharacteristics() override;
43 bool readAppearanceCharacteristic();
44 bool readDeviceNameCharacteristic();
45
46 // Appearance characteristic (BLE read only).
47 quint16 appearance() const;
48
49 // Device Name characteristic (BLE read/write).
50 QString deviceName() const;
51 bool setDeviceName(const QString &name);
52
53signals:
54 void appearanceRead(const quint16 appearance);
55 void deviceNameRead(const QString &deviceName);
57
58protected:
59 /// \cond internal
60 GenericAccessService(GenericAccessServicePrivate * const d, QObject * const parent);
61 /// \endcond
62
63private:
64 Q_DECLARE_PRIVATE(GenericAccessService)
66 friend class TestGenericAccessService;
67};
68
69QTPOKIT_END_NAMESPACE
70
71#endif // QTPOKIT_GENERICACCESSSERVICE_H
Declares the AbstractPokitService class.
The AbstractPokitService class provides a common base for Pokit services classes.
Definition abstractpokitservice.h:27
virtual bool readCharacteristics()=0
Read all characteristics.
The GenericAccessService class accesses the Generic Access service of Pokit devices.
Definition genericaccessservice.h:23
void deviceNameWritten()
This signal is emitted when the Device Name characteristic has been written successfully.
void deviceNameRead(const QString &deviceName)
This signal is emitted when the Device Name characteristic has been read successfully.
void appearanceRead(const quint16 appearance)
This signal is emitted when the Appearance characteristic has been read successfully.
Q_DISABLE_COPY(Class)
Characteristics available via the Generic Access service.
Definition genericaccessservice.h:31