Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
26
namespace
QtBluetoothPrivate
{
27
28
class
OrgFreedesktopDBusPropertiesAdaptor
;
29
class
OrgBluezGattCharacteristic1Adaptor
;
30
class
OrgBluezGattDescriptor1Adaptor;
31
class
OrgBluezGattService1Adaptor
;
32
33
}
// namespace QtBluetoothPrivate
34
35
QT_BEGIN_NAMESPACE
36
37
// The QtBluezPeripheralGattObject is the base class for services, characteristics, and descriptors
38
class
QtBluezPeripheralGattObject :
public
QObject
39
{
40
Q_OBJECT
41
42
public
:
43
QtBluezPeripheralGattObject(
const
QString& objectPath,
const
QString& uuid,
44
QLowEnergyHandle handle, QObject* parent =
nullptr
);
45
virtual
~QtBluezPeripheralGattObject();
46
47
// List of properties exposed by this object, used when Bluez inquiries details
48
virtual
InterfaceList properties()
const
= 0;
49
50
bool
registerObject();
51
void
unregisterObject();
52
53
public
:
54
// DBus object path
55
QString objectPath;
56
// UUID of the gatt object
57
QString uuid;
58
// QtBluetooth internal handle and reference to the application
59
// to read and write values towards the Qt API
60
QLowEnergyHandle handle;
61
// Bluez DBus Gatt objects need to provide this
62
QtBluetoothPrivate::OrgFreedesktopDBusPropertiesAdaptor* propertiesAdaptor{};
63
64
signals:
65
void
remoteDeviceAccessEvent(
const
QString& remoteDeviceObjectPath, quint16 mtu);
66
67
protected
:
68
void
accessEvent(
const
QVariantMap& options);
69
70
private
:
71
bool
m_registered =
false
;
72
};
73
74
class
QtBluezPeripheralDescriptor
:
public
QtBluezPeripheralGattObject
75
{
76
Q_OBJECT
77
78
public
:
79
QtBluezPeripheralDescriptor
(
const
QLowEnergyDescriptorData
&
descriptorData
,
80
const
QString
&
characteristicPath
,
quint16
ordinal
,
81
QLowEnergyHandle
handle
,
QLowEnergyHandle
characteristicHandle
,
82
QObject
*
parent
);
83
84
InterfaceList
properties
()
const
final
;
85
86
// org.bluez.GattDescriptor1
87
// This function is invoked when remote device reads the value. Sets error if any
88
Q_INVOKABLE QByteArray
ReadValue
(
const
QVariantMap
&
options
,
QString
&
error
);
89
90
// org.bluez.GattDescriptor1
91
// This function is invoked when remote device writes a value. Returns Bluez DBus error if any
92
Q_INVOKABLE QString
WriteValue
(
const
QByteArray
&
value
,
const
QVariantMap
&
options
);
93
94
// Call this function when value has been updated locally (server/user application side)
95
bool
localValueUpdate
(
const
QByteArray& value);
96
97
signals
:
98
void
valueUpdatedByRemote
(
QLowEnergyHandle
characteristicHandle
,
99
QLowEnergyHandle
descriptorHandle
,
const
QByteArray
&
value
);
100
101
private
:
102
void
initializeFlags(
const
QLowEnergyDescriptorData& data);
103
104
QtBluetoothPrivate
::OrgBluezGattDescriptor1Adaptor* m_adaptor{};
105
QString m_characteristicPath;
106
QByteArray m_value;
107
QStringList m_flags;
108
QLowEnergyHandle m_characteristicHandle;
109
};
110
111
112
class
QtBluezPeripheralCharacteristic
:
public
QtBluezPeripheralGattObject
113
{
114
Q_OBJECT
115
116
public
:
117
QtBluezPeripheralCharacteristic
(
const
QLowEnergyCharacteristicData
&
characteristicData
,
118
const
QString
&
servicePath
,
quint16
ordinal
,
119
QLowEnergyHandle
handle
,
QObject
*
parent
);
120
121
InterfaceList
properties
()
const
final
;
122
123
// org.bluez.GattCharacteristic1
124
// This function is invoked when remote device reads the value. Sets error if any
125
Q_INVOKABLE QByteArray
ReadValue
(
const
QVariantMap
&
options
,
QString
&
error
);
126
127
// org.bluez.GattCharacteristic1
128
// This function is invoked when remote device writes a value. Returns Bluez DBus error if any
129
Q_INVOKABLE QString
WriteValue
(
const
QByteArray
&
value
,
const
QVariantMap
&
options
);
130
131
// org.bluez.GattCharacteristic1
132
// These are called when remote client enables or disables NTF/IND
133
Q_INVOKABLE
void
StartNotify
();
134
Q_INVOKABLE
void
StopNotify
();
135
136
// Call this function when value has been updated locally (server/user application side)
137
bool
localValueUpdate
(
const
QByteArray& value);
138
139
signals
:
140
void
valueUpdatedByRemote
(
QLowEnergyHandle
handle
,
const
QByteArray
&
value
);
141
142
private
:
143
void
initializeValue(
const
QByteArray& value);
144
void
initializeFlags(
const
QLowEnergyCharacteristicData& data);
145
146
QtBluetoothPrivate
::
OrgBluezGattCharacteristic1Adaptor
* m_adaptor{};
147
QString m_servicePath;
148
bool
m_notifying{
false
};
149
QByteArray m_value;
150
QStringList m_flags;
151
int
m_minimumValueLength;
152
int
m_maximumValueLength;
153
};
154
155
class
QtBluezPeripheralService
:
public
QtBluezPeripheralGattObject
156
{
157
Q_OBJECT
158
public
:
159
QtBluezPeripheralService
(
const
QLowEnergyServiceData
&
serviceData
,
160
const
QString
&
applicationPath
,
quint16
ordinal
,
161
QLowEnergyHandle
handle
,
QObject
*
parent
);
162
163
InterfaceList
properties
()
const
final
;
164
void
addIncludedService
(
const
QString& objectPath);
165
166
private
:
167
const
bool
m_isPrimary;
168
QtBluetoothPrivate
::
OrgBluezGattService1Adaptor
* m_adaptor{};
169
QList<QDBusObjectPath> m_includedServices;
170
};
171
172
173
QT_END_NAMESPACE
174
175
#
endif
ManagedObjectList
QMap< QDBusObjectPath, InterfaceList > ManagedObjectList
Definition
bluez5_helper_p.h:25
InterfaceList
QMap< QString, QVariantMap > InterfaceList
Definition
bluez5_helper_p.h:24
appObjectPathTemplate
static constexpr QLatin1String appObjectPathTemplate
Definition
bluezperipheralapplication.cpp:16
QtBluetoothPrivate::OrgBluezGattCharacteristic1Adaptor
Definition
gattcharacteristic1adaptor_p.h:37
QtBluetoothPrivate::OrgBluezGattManager1Interface
Definition
gattmanager1_p.h:41
QtBluetoothPrivate::OrgBluezGattService1Adaptor
Definition
gattservice1adaptor_p.h:37
QtBluetoothPrivate::OrgFreedesktopDBusObjectManagerAdaptor
Definition
objectmanageradaptor_p.h:37
QtBluetoothPrivate::OrgFreedesktopDBusPropertiesAdaptor
Definition
propertiesadaptor_p.h:37
QtBluezPeripheralApplication
Definition
bluezperipheralapplication_p.h:40
QtBluezPeripheralApplication::~QtBluezPeripheralApplication
~QtBluezPeripheralApplication()
Definition
bluezperipheralapplication.cpp:31
QtBluezPeripheralApplication::localDescriptorWrite
bool localDescriptorWrite(QLowEnergyHandle handle, const QByteArray &value)
Definition
bluezperipheralapplication.cpp:225
QtBluezPeripheralApplication::unregisterApplication
void unregisterApplication()
Definition
bluezperipheralapplication.cpp:84
QtBluezPeripheralApplication::remoteDeviceAccessEvent
void remoteDeviceAccessEvent(const QString &remoteDeviceObjectPath, quint16 mtu)
QtBluezPeripheralApplication::registerApplication
void registerApplication()
Definition
bluezperipheralapplication.cpp:36
QtBluezPeripheralApplication::addService
void addService(const QLowEnergyServiceData &serviceData, QSharedPointer< QLowEnergyServicePrivate > servicePrivate, QLowEnergyHandle serviceHandle)
Definition
bluezperipheralapplication.cpp:135
QtBluezPeripheralApplication::reset
void reset()
Definition
bluezperipheralapplication.cpp:123
QtBluezPeripheralApplication::characteristicValueUpdatedByRemote
void characteristicValueUpdatedByRemote(QLowEnergyHandle handle, const QByteArray &value)
QtBluezPeripheralApplication::registered
void registered()
QtBluezPeripheralApplication::registrationNeeded
bool registrationNeeded()
Definition
bluezperipheralapplication.cpp:236
QtBluezPeripheralApplication::localCharacteristicWrite
bool localCharacteristicWrite(QLowEnergyHandle handle, const QByteArray &value)
Definition
bluezperipheralapplication.cpp:213
QtBluezPeripheralApplication::descriptorValueUpdatedByRemote
void descriptorValueUpdatedByRemote(QLowEnergyHandle characteristicHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value)
QtBluezPeripheralCharacteristic
Definition
bluezperipheralobjects_p.h:113
QtBluezPeripheralCharacteristic::properties
InterfaceList properties() const final
Definition
bluezperipheralobjects.cpp:215
QtBluezPeripheralCharacteristic::StopNotify
Q_INVOKABLE void StopNotify()
Definition
bluezperipheralobjects.cpp:301
QtBluezPeripheralCharacteristic::StartNotify
Q_INVOKABLE void StartNotify()
Definition
bluezperipheralobjects.cpp:295
QtBluezPeripheralCharacteristic::localValueUpdate
bool localValueUpdate(const QByteArray &value)
Definition
bluezperipheralobjects.cpp:277
QtBluezPeripheralConnectionManager
Definition
bluezperipheralconnectionmanager_p.h:36
QtBluezPeripheralDescriptor
Definition
bluezperipheralobjects_p.h:75
QtBluezPeripheralDescriptor::localValueUpdate
bool localValueUpdate(const QByteArray &value)
Definition
bluezperipheralobjects.cpp:161
QtBluezPeripheralDescriptor::properties
InterfaceList properties() const final
Definition
bluezperipheralobjects.cpp:101
QtBluezPeripheralService
Definition
bluezperipheralobjects_p.h:156
QtBluezPeripheralService::addIncludedService
void addIncludedService(const QString &objectPath)
Definition
bluezperipheralobjects.cpp:388
QtBluezPeripheralService::properties
InterfaceList properties() const final
Definition
bluezperipheralobjects.cpp:393
QtBluetoothPrivate
Definition
adapter1_bluez5.cpp:14
qtconnectivity
src
bluetooth
bluez
bluezperipheralobjects_p.h
Generated on
for Qt by
1.18.0