Dokit
Native Qt library for Pokit devices
Loading...
Searching...
No Matches
deviceinfoservice.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 DeviceInfoService class.
7 */
8
9#ifndef QTPOKIT_INFOSERVICE_H
10#define QTPOKIT_INFOSERVICE_H
11
13
14#include <QBluetoothAddress>
15#include <QBluetoothUuid>
16#include <QVersionNumber>
17
18QTPOKIT_BEGIN_NAMESPACE
19
20class DeviceInfoServicePrivate;
21
22class QTPOKIT_EXPORT DeviceInfoService : public AbstractPokitService
23{
24 Q_OBJECT
25
26public:
27 /// UUID of the "Device Info" service.
28 static inline const QBluetoothUuid serviceUuid
29 { QBluetoothUuid::ServiceClassUuid::DeviceInformation };
30
31 /// Characteristics available via the `Device Info` service.
32 struct QTPOKIT_EXPORT CharacteristicUuids {
33 /// UUID of the `Device Info` service's `Manufacturer Name String` characterstic.
34 static inline const QBluetoothUuid manufacturerName
35 { QBluetoothUuid::CharacteristicType::ManufacturerNameString };
36
37 /// UUID of the `Device Info` service's `Model Number String` characterstic.
38 static inline const QBluetoothUuid modelNumber
39 { QBluetoothUuid::CharacteristicType::ModelNumberString };
40
41 /// UUID of the `Device Info` service's `Firmware Revision String` characterstic.
42 static inline const QBluetoothUuid firmwareRevision
43 { QBluetoothUuid::CharacteristicType::FirmwareRevisionString };
44
45 /// UUID of the `Device Info` service's `Hardware Revision String` characterstic.
46 static inline const QBluetoothUuid hardwareRevision
47 { QBluetoothUuid::CharacteristicType::HardwareRevisionString };
48
49 /// UUID of the `Device Info` service's `Software Revision String` characterstic.
50 static inline const QBluetoothUuid softwareRevision
51 { QBluetoothUuid::CharacteristicType::SoftwareRevisionString };
52
53 /// UUID of the `Device Info` service's `Serial Number String` characterstic.
54 static inline const QBluetoothUuid serialNumber
55 { QBluetoothUuid::CharacteristicType::SerialNumberString };
56 };
57
58 DeviceInfoService(QLowEnergyController * const pokitDevice, QObject * parent = nullptr);
59 ~DeviceInfoService() override;
60
61 bool readCharacteristics() override;
62 bool readFirmwareRevisionCharacteristic();
63 bool readHardwareRevisionCharacteristic();
64 bool readManufacturerCharacteristics();
65 bool readModelNumberCharacteristic();
66 bool readSoftwareRevisionCharacteristic();
67 bool readSerialNumberCharacteristic();
68
69 // All Device Info characteristics are read-only, single values.
70 QString manufacturer() const;
71 QString modelNumber() const;
72 QString hardwareRevision() const;
73 QString firmwareRevision() const;
74 QString softwareRevision() const;
75 QString serialNumber() const;
76
77signals:
78 void manufacturerRead(const QString &name);
79 void modelNumberRead(const QString &model);
80 void hardwareRevisionRead(const QString &revision);
81 void firmwareRevisionRead(const QString &revision);
82 void softwareRevisionRead(const QString &revision);
83 void serialNumberRead(const QString &serialNumber);
84
85protected:
86 /// \cond internal
87 DeviceInfoService(DeviceInfoServicePrivate * const d, QObject * const parent);
88 /// \endcond
89
90private:
91 Q_DECLARE_PRIVATE(DeviceInfoService)
93 friend class TestDeviceInfoService;
94};
95
96QTPOKIT_END_NAMESPACE
97
98#endif // QTPOKIT_INFOSERVICE_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 DeviceInfoService class accesses the Device Info service of Pokit devices.
Definition deviceinfoservice.h:23
void hardwareRevisionRead(const QString &revision)
This signal is emitted when the Hardware Revision characteristic has been read successfully.
void firmwareRevisionRead(const QString &revision)
This signal is emitted when the Firmware Revision characteristic has been read successfully.
void softwareRevisionRead(const QString &revision)
This signal is emitted when the Software Revision characteristic has been read successfully.
void modelNumberRead(const QString &model)
This signal is emitted when the Model Number characteristic has been read successfully.
void manufacturerRead(const QString &name)
This signal is emitted when the Manufacturer Name characteristic has been read successfully.
void serialNumberRead(const QString &serialNumber)
This signal is emitted when the Serial Number characteristic has been read successfully.
Q_DISABLE_COPY(Class)
Characteristics available via the Device Info service.
Definition deviceinfoservice.h:32