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
qlowenergyservice.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Javier S. Pedro <maemo@javispedro.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4#ifndef QLOWENERGYSERVICE_H
5#define QLOWENERGYSERVICE_H
6
7#include <QtBluetooth/QBluetoothAddress>
8#include <QtBluetooth/QBluetoothUuid>
9#include <QtBluetooth/QLowEnergyCharacteristic>
10
12
14class Q_BLUETOOTH_EXPORT QLowEnergyService : public QObject
15{
17public:
19 PrimaryService = 0x0001,
20 IncludedService = 0x0002
21 };
22 Q_ENUM(ServiceType)
23 Q_DECLARE_FLAGS(ServiceTypes, ServiceType)
24
34 Q_ENUM(ServiceError)
35
37 InvalidService = 0,
39 RemoteServiceDiscovering, // discoverDetails() called and running
40 RemoteServiceDiscovered, // all details have been synchronized
42
43#if QT_DEPRECATED_SINCE(6, 2)
44// for source compatibility:
45 DiscoveryRequired
47 "DiscoveryRequired was renamed to RemoteService.")
48 = RemoteService,
49 DiscoveringService
51 "DiscoveringService was renamed to RemoteServiceDiscovering.")
52 = RemoteServiceDiscovering,
53 ServiceDiscovered
55 "ServiceDiscovered was renamed to RemoteServiceDiscovered.")
56 = RemoteServiceDiscovered,
57#endif
58 };
59 Q_ENUM(ServiceState)
60
62 FullDiscovery, // standard, reads all attributes
63 SkipValueDiscovery // does not read characteristic values and descriptors
64 };
66
67 enum WriteMode {
68 WriteWithResponse = 0,
70 WriteSigned
71 };
72 Q_ENUM(WriteMode)
73
75
76 QList<QBluetoothUuid> includedServices() const;
77
78 QLowEnergyService::ServiceTypes type() const;
80
81 QLowEnergyCharacteristic characteristic(const QBluetoothUuid &uuid) const;
82 QList<QLowEnergyCharacteristic> characteristics() const;
83 QBluetoothUuid serviceUuid() const;
84 QString serviceName() const;
85
86 void discoverDetails(DiscoveryMode mode = FullDiscovery);
87
88 ServiceError error() const;
89
90 bool contains(const QLowEnergyCharacteristic &characteristic) const;
91 void readCharacteristic(const QLowEnergyCharacteristic &characteristic);
92 void writeCharacteristic(const QLowEnergyCharacteristic &characteristic,
93 const QByteArray &newValue,
94 WriteMode mode = WriteWithResponse);
95
96 bool contains(const QLowEnergyDescriptor &descriptor) const;
97 void readDescriptor(const QLowEnergyDescriptor &descriptor);
98 void writeDescriptor(const QLowEnergyDescriptor &descriptor,
99 const QByteArray &newValue);
100
104 const QByteArray &value);
106 const QByteArray &value);
108 const QByteArray &value);
110 const QByteArray &value);
112 const QByteArray &value);
114
115private:
116 Q_DECLARE_PRIVATE(QLowEnergyService)
117 QSharedPointer<QLowEnergyServicePrivate> d_ptr;
118
119 // QLowEnergyController is the factory for this class
125 QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> p,
126 QObject *parent = nullptr);
127};
128
129Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyService::ServiceTypes)
130
132
134 Q_BLUETOOTH_EXPORT)
136 Q_BLUETOOTH_EXPORT)
138 Q_BLUETOOTH_EXPORT)
140 Q_BLUETOOTH_EXPORT)
141
142#endif // QLOWENERGYSERVICE_H
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtBluetooth
\inmodule QtBluetooth
\inmodule QtBluetooth
void characteristicChanged(const QLowEnergyCharacteristic &info, const QByteArray &value)
If the associated controller object is in the \l {QLowEnergyController::CentralRole}{central} role,...
void descriptorRead(const QLowEnergyDescriptor &info, const QByteArray &value)
This signal is emitted when the read request for descriptor successfully returned its value.
void stateChanged(QLowEnergyService::ServiceState newState)
This signal is emitted when the service's state changes.
void errorOccurred(QLowEnergyService::ServiceError error)
This signal is emitted when an error occurrs.
DiscoveryMode
This enum lists service discovery modes.
void characteristicRead(const QLowEnergyCharacteristic &info, const QByteArray &value)
This signal is emitted when the read request for characteristic successfully returned its value.
void characteristicWritten(const QLowEnergyCharacteristic &info, const QByteArray &value)
This signal is emitted when the value of characteristic is successfully changed to newValue.
ServiceError
This enum describes all possible error conditions during the service's existence.
ServiceState
This enum describes the \l state() of the service object.
WriteMode
This enum describes the mode to be used when writing a characteristic value.
void descriptorWritten(const QLowEnergyDescriptor &info, const QByteArray &value)
This signal is emitted when the value of descriptor is successfully changed to newValue.
ServiceType
This enum describes the type of the service.
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
else opt state
[0]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
#define Q_DECL_ENUMERATOR_DEPRECATED_X(x)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1376
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLenum mode
GLenum type
GLfloat GLfloat p
[1]
@ NoError
Definition main.cpp:34
#define Q_ENUM(x)
#define Q_OBJECT
#define Q_SIGNALS
QHostInfo info
[0]