Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
bluezperipheralobjects_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef BLUEZ_PERIPHERAL_OBJECTS_P_H
5#define BLUEZ_PERIPHERAL_OBJECTS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "bluez5_helper_p.h"
19
20#include <QtBluetooth/qbluetooth.h>
21#include <QtBluetooth/QBluetoothUuid>
22#include <QtBluetooth/QLowEnergyDescriptorData>
23#include <QtBluetooth/QLowEnergyCharacteristicData>
24#include <QtBluetooth/QLowEnergyServiceData>
25
30
32
33// The QtBluezPeripheralGattObject is the base class for services, characteristics, and descriptors
35{
37
38public:
42
43 // List of properties exposed by this object, used when Bluez inquiries details
44 virtual InterfaceList properties() const = 0;
45
46 bool registerObject();
47 void unregisterObject();
48
49public:
50 // DBus object path
52 // UUID of the gatt object
54 // QtBluetooth internal handle and reference to the application
55 // to read and write values towards the Qt API
57 // Bluez DBus Gatt objects need to provide this
59
61 void remoteDeviceAccessEvent(const QString& remoteDeviceObjectPath, quint16 mtu);
62
63protected:
64 void accessEvent(const QVariantMap& options);
65
66private:
67 bool m_registered = false;
68};
69
71{
73
74public:
76 const QString& characteristicPath, quint16 ordinal,
77 QLowEnergyHandle handle, QLowEnergyHandle characteristicHandle,
79
80 InterfaceList properties() const final;
81
82 // org.bluez.GattDescriptor1
83 // This function is invoked when remote device reads the value. Sets error if any
85
86 // org.bluez.GattDescriptor1
87 // This function is invoked when remote device writes a value. Returns Bluez DBus error if any
89
90 // Call this function when value has been updated locally (server/user application side)
92
94 void valueUpdatedByRemote(QLowEnergyHandle characteristicHandle,
95 QLowEnergyHandle descriptorHandle, const QByteArray& value);
96
97private:
98 void initializeFlags(const QLowEnergyDescriptorData& data);
99
101 QString m_characteristicPath;
102 QByteArray m_value;
103 QStringList m_flags;
104 QLowEnergyHandle m_characteristicHandle;
105};
106
107
109{
111
112public:
114 const QString& servicePath, quint16 ordinal,
116
117 InterfaceList properties() const final;
118
119 // org.bluez.GattCharacteristic1
120 // This function is invoked when remote device reads the value. Sets error if any
122
123 // org.bluez.GattCharacteristic1
124 // This function is invoked when remote device writes a value. Returns Bluez DBus error if any
126
127 // org.bluez.GattCharacteristic1
128 // These are called when remote client enables or disables NTF/IND
130 Q_INVOKABLE void StopNotify();
131
132 // Call this function when value has been updated locally (server/user application side)
133 bool localValueUpdate(const QByteArray& value);
134
135signals:
137
138private:
139 void initializeValue(const QByteArray& value);
140 void initializeFlags(const QLowEnergyCharacteristicData& data);
141
143 QString m_servicePath;
144 bool m_notifying{false};
145 QByteArray m_value;
146 QStringList m_flags;
147 int m_minimumValueLength;
148 int m_maximumValueLength;
149};
150
152{
154public:
156 const QString& applicationPath, quint16 ordinal,
158
159 InterfaceList properties() const final;
161
162private:
163 const bool m_isPrimary;
164 OrgBluezGattService1Adaptor* m_adaptor{};
165 QList<QDBusObjectPath> m_includedServices;
166};
167
168
170
171#endif
\inmodule QtCore
Definition qbytearray.h:57
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
The QLowEnergyDescriptorData class is used to create GATT service data. \inmodule QtBluetooth.
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
Definition qmap.h:187
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Q_INVOKABLE QString WriteValue(const QByteArray &value, const QVariantMap &options)
InterfaceList properties() const final
QtBluezPeripheralCharacteristic(const QLowEnergyCharacteristicData &characteristicData, const QString &servicePath, quint16 ordinal, QLowEnergyHandle handle, QObject *parent)
Q_INVOKABLE QByteArray ReadValue(const QVariantMap &options, QString &error)
void valueUpdatedByRemote(QLowEnergyHandle handle, const QByteArray &value)
bool localValueUpdate(const QByteArray &value)
Q_INVOKABLE QString WriteValue(const QByteArray &value, const QVariantMap &options)
QtBluezPeripheralDescriptor(const QLowEnergyDescriptorData &descriptorData, const QString &characteristicPath, quint16 ordinal, QLowEnergyHandle handle, QLowEnergyHandle characteristicHandle, QObject *parent)
Q_INVOKABLE QByteArray ReadValue(const QVariantMap &options, QString &error)
bool localValueUpdate(const QByteArray &value)
void valueUpdatedByRemote(QLowEnergyHandle characteristicHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value)
InterfaceList properties() const final
OrgFreedesktopDBusPropertiesAdaptor * propertiesAdaptor
void accessEvent(const QVariantMap &options)
void remoteDeviceAccessEvent(const QString &remoteDeviceObjectPath, quint16 mtu)
QtBluezPeripheralGattObject(const QString &objectPath, const QString &uuid, QLowEnergyHandle handle, QObject *parent=nullptr)
virtual InterfaceList properties() const =0
void addIncludedService(const QString &objectPath)
InterfaceList properties() const final
QtBluezPeripheralService(const QLowEnergyServiceData &serviceData, const QString &applicationPath, quint16 ordinal, QLowEnergyHandle handle, QObject *parent)
Combined button and popup list for selecting options.
quint16 QLowEnergyHandle
Definition qbluetooth.h:42
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_OBJECT
#define Q_INVOKABLE
#define signals
unsigned short quint16
Definition qtypes.h:48