BluezQt

gattcharacteristic.cpp
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 #include "gattcharacteristic.h"
10 #include "gattcharacteristic_p.h"
11 #include "gattservice.h"
12 
13 namespace BluezQt
14 {
15 GattCharacteristic::GattCharacteristic(const QString &uuid, GattService *service)
16  : QObject(service)
17  , d(new GattCharacterisiticPrivate(uuid, service))
18 {
19 }
20 
21 GattCharacteristic::~GattCharacteristic()
22 {
23  delete d;
24 }
25 
26 QByteArray GattCharacteristic::readValue()
27 {
28  if (d->m_readCallback) {
29  d->m_value = d->m_readCallback();
30  }
31 
32  return d->m_value;
33 }
34 
35 void GattCharacteristic::writeValue(const QByteArray &value)
36 {
37  d->m_value = value;
38  Q_EMIT valueWritten(d->m_value);
39 }
40 
41 QString GattCharacteristic::uuid() const
42 {
43  return d->m_uuid;
44 }
45 
46 const GattService *GattCharacteristic::service() const
47 {
48  return d->m_service;
49 }
50 
51 QDBusObjectPath GattCharacteristic::objectPath() const
52 {
53  return d->m_objectPath;
54 }
55 
56 void GattCharacteristic::setReadCallback(ReadCallback callback)
57 {
58  d->m_readCallback = callback;
59 }
60 
61 } // 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.