Line data Source code
1 : // SPDX-FileCopyrightText: 2022 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 : 12 : #include "abstractpokitservice.h" 13 : 14 : #include <QBluetoothAddress> 15 : #include <QBluetoothUuid> 16 : #include <QVersionNumber> 17 : 18 : QTPOKIT_BEGIN_NAMESPACE 19 : 20 : class GenericAccessServicePrivate; 21 : 22 : class QTPOKIT_EXPORT GenericAccessService : public AbstractPokitService 23 : { 24 17 : Q_OBJECT 25 : 26 : public: 27 : static const QBluetoothUuid serviceUuid; 28 : 29 : struct QTPOKIT_EXPORT CharacteristicUuids { 30 : static const QBluetoothUuid deviceName; 31 : static const QBluetoothUuid appearance; 32 : }; 33 : 34 : GenericAccessService(QLowEnergyController * const pokitDevice, QObject * parent = nullptr); 35 : ~GenericAccessService() override; 36 : 37 : bool readCharacteristics() override; 38 : bool readAppearanceCharacteristic(); 39 : bool readDeviceNameCharacteristic(); 40 : 41 : // Appearance characteristic (BLE read only). 42 : quint16 appearance() const; 43 : 44 : // Device Name characteristic (BLE read/write). 45 : QString deviceName() const; 46 : bool setDeviceName(const QString &name); 47 : 48 : signals: 49 : void appearanceRead(const quint16 appearance); 50 : void deviceNameRead(const QString &deviceName); 51 : void deviceNameWritten(); 52 : 53 : protected: 54 : /// \cond internal 55 : GenericAccessService(GenericAccessServicePrivate * const d, QObject * const parent); 56 : /// \endcond 57 : 58 : private: 59 48 : Q_DECLARE_PRIVATE(GenericAccessService) 60 : Q_DISABLE_COPY(GenericAccessService) 61 : friend class TestGenericAccessService; 62 : }; 63 : 64 : QTPOKIT_END_NAMESPACE 65 : 66 : #endif // QTPOKIT_GENERICACCESSSERVICE_H