BluezQt

gattcharacteristic.h
1 /*
2  * BluezQt - Asynchronous BlueZ wrapper library
3  *
4  * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #ifndef BLUEZQT_GATTCHARACTERISTIC_H
10 #define BLUEZQT_GATTCHARACTERISTIC_H
11 
12 #include "bluezqt_export.h"
13 
14 #include <QDBusObjectPath>
15 
16 namespace BluezQt
17 {
18 class GattService;
19 
20 class BLUEZQT_EXPORT GattCharacteristic : public QObject
21 {
22  Q_OBJECT
23 
24 public:
25  /**
26  * Creates a new GattCharacteristic object.
27  *
28  * @param parent
29  */
30  explicit GattCharacteristic(const QString &uuid, GattService *service);
31 
32  /**
33  * Destroys a GattCharacteristic object.
34  */
35  ~GattCharacteristic() override;
36 
37  /**
38  * Reads the value of the characteristic.
39  */
40  QByteArray readValue();
41 
42  /**
43  * Writes the value of the characteristic.
44  */
45  void writeValue(const QByteArray &value);
46 
47  /**
48  * Provide a read callback to operate in *pull* mode.
49  */
50  using ReadCallback = std::function<QByteArray()>;
51  void setReadCallback(ReadCallback callback);
52 
53  /**
54  * 128-bit GATT characteristic UUID.
55  *
56  * @return uuid of characteristic
57  */
58  QString uuid() const;
59 
60  /**
61  * The GATT service the characteristic belongs to.
62  *
63  * @return service this characteristic belongs to
64  */
65  const GattService *service() const;
66 
67 Q_SIGNALS:
68  /**
69  * Indicates that a value was written.
70  */
71  void valueWritten(const QByteArray &value);
72 
73 protected:
74  /**
75  * D-Bus object path of the GattCharacteristic.
76  *
77  * The path where the GattCharacteristic will be registered.
78  *
79  * @note You must provide valid object path!
80  *
81  * @return object path of GattCharacteristic
82  */
83  virtual QDBusObjectPath objectPath() const;
84 
85 private:
86  class GattCharacterisiticPrivate *const d;
87 
88  friend class GattApplicationPrivate;
89  friend class GattCharacteristicAdaptor;
90  friend class GattManager;
91 };
92 
93 } // namespace BluezQt
94 
95 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 23 2023 04:07:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.