11#include <QtCore/QLoggingCategory>
12#include <QtDBus/QDBusConnection>
75 if (!remoteDevice.isEmpty())
87 m_characteristicPath(characteristicPath),
88 m_characteristicHandle(characteristicHandle)
91 qCWarning(QT_BT_BLUEZ) <<
"Descriptor value is too large, cropping it to"
95 m_value = descriptorData.
value();
97 initializeFlags(descriptorData);
107 {
"Flags"_L1, m_flags}
143 if (options.
value(
"prepare-authorize"_L1).
toBool()) {
145 qCWarning(QT_BT_BLUEZ) <<
"Descriptor write requires authorization."
146 <<
"The client device needs to be trusted beforehand";
151 qCWarning(QT_BT_BLUEZ) <<
"Descriptor value is too large:" <<
value.size();
163 qCWarning(QT_BT_BLUEZ) <<
"Descriptor value is too large:" <<
value.size();
173 if (
data.isReadable())
174 m_flags.append(
"read"_L1);
176 m_flags.append(
"encrypt-read"_L1);
178 m_flags.append(
"encrypt-authenticated-read"_L1);
180 if (
data.isWritable())
181 m_flags.append(
"write"_L1);
183 m_flags.append(
"encrypt-write"_L1);
185 m_flags.append(
"encrypt-authenticated-write"_L1);
189 m_flags.append(
"authorize"_L1);
191 if (m_flags.isEmpty()) {
192 qCWarning(QT_BT_BLUEZ) <<
"Descriptor property flags not set" <<
uuid
193 <<
"Peripheral may fail to register";
204 m_servicePath(servicePath),
205 m_minimumValueLength(
std::min(characteristicData.minimumValueLength(),
207 m_maximumValueLength(
std::min(characteristicData.maximumValueLength(),
210 initializeFlags(characteristicData);
211 initializeValue(characteristicData.
value());
221 {
"Flags"_L1, m_flags}
257 if (options.
value(
"prepare-authorize"_L1).
toBool()) {
259 qCWarning(QT_BT_BLUEZ) <<
"Characteristic write requires authorization."
260 <<
"The client device needs to be trusted beforehand";
264 if (
value.size() < m_minimumValueLength ||
value.size() > m_maximumValueLength) {
265 qCWarning(QT_BT_BLUEZ) <<
"Characteristic value has invalid length" <<
value.size()
266 <<
"min:" << m_minimumValueLength
267 <<
"max:" << m_maximumValueLength;
278 if (
value.size() < m_minimumValueLength ||
value.size() > m_maximumValueLength) {
279 qCWarning(QT_BT_BLUEZ) <<
"Characteristic value has invalid length" <<
value.size()
280 <<
"min:" << m_minimumValueLength
281 <<
"max:" << m_maximumValueLength;
296 qCDebug(QT_BT_BLUEZ) <<
"NTF or IND enabled for characteristic" <<
uuid;
302 qCDebug(QT_BT_BLUEZ) <<
"NTF or IND disabled for characteristic" <<
uuid;
307void QtBluezPeripheralCharacteristic::initializeValue(
const QByteArray&
value)
309 const auto valueSize =
value.size();
310 if (valueSize < m_minimumValueLength || valueSize > m_maximumValueLength) {
311 qCWarning(QT_BT_BLUEZ) <<
"Characteristic value has invalid length" << valueSize
312 <<
"min:" << m_minimumValueLength
313 <<
"max:" << m_maximumValueLength;
314 m_value =
QByteArray(m_minimumValueLength, 0);
324 m_flags.append(
"broadcast"_L1);
326 m_flags.append(
"write-without-response"_L1);
328 m_flags.append(
"read"_L1);
330 m_flags.append(
"write"_L1);
332 m_flags.append(
"notify"_L1);
334 m_flags.append(
"indicate"_L1);
336 m_flags.append(
"authenticated-signed-writes"_L1);
342 for (
const auto& descriptor :
data.descriptors()) {
344 if (descriptor.uuid()
346 && descriptor.value().size() == 2) {
349 m_flags.append(
"reliable-write"_L1);
351 m_flags.append(
"writable-auxiliaries"_L1);
357 m_flags.append(
"encrypt-read"_L1);
359 m_flags.append(
"encrypt-authenticated-read"_L1);
361 m_flags.append(
"encrypt-write"_L1);
363 m_flags.append(
"encrypt-authenticated-write"_L1);
367 m_flags.append(
"authorize"_L1);
369 if (m_flags.isEmpty()) {
370 qCWarning(QT_BT_BLUEZ) <<
"Characteristic property flags not set" <<
uuid
371 <<
"Peripheral may fail to register";
395 {
"Primary"_L1, m_isPrimary},
403#include "moc_bluezperipheralobjects_p.cpp"
static constexpr auto servicePathTemplate
static constexpr auto descriptorPathTemplate
static constexpr auto characteristicPathTemplate
static constexpr auto bluezErrorInvalidOffset
static constexpr auto bluezServiceInterface
static constexpr int maximumAttributeLength
static constexpr auto bluezErrorInvalidValueLength
static constexpr auto bluezCharacteristicInterface
static constexpr auto bluezDescriptorInterface
static constexpr auto bluezErrorNotAuthorized
void PropertiesChanged(const QString &interface, const QVariantMap &changed_properties, const QStringList &invalidated_properties)
@ CharacteristicExtendedProperties
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
qsizetype length() const noexcept
Same as size().
QByteArray sliced(qsizetype pos) const
QByteArray mid(qsizetype index, qsizetype len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos.
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
void unregisterObject(const QString &path, UnregisterMode mode=UnregisterNode)
Unregisters an object that was registered with the registerObject() at the object path given by path ...
void append(parameter_type t)
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
QByteArray value() const
Returns the value of this characteristic.
The QLowEnergyDescriptorData class is used to create GATT service data. \inmodule QtBluetooth.
QByteArray value() const
Returns the value of this descriptor.
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
uint toUInt(bool *ok=nullptr) const
Returns the variant as an unsigned int if the variant has userType() \l QMetaType::UInt,...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
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 void StopNotify()
Q_INVOKABLE void StartNotify()
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 ~QtBluezPeripheralGattObject()
void addIncludedService(const QString &objectPath)
InterfaceList properties() const final
QtBluezPeripheralService(const QLowEnergyServiceData &serviceData, const QString &applicationPath, quint16 ordinal, QLowEnergyHandle handle, QObject *parent)
@ AttAuthorizationRequired
@ AttAuthenticationRequired
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLsizei const GLchar *const * path
char * toString(const MyType &t)
[31]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent