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

KDE's Doxygen guidelines are available online.