9#include <QtCore/QtMinMax>
10#include <QtCore/QLoggingCategory>
38 m_advData(advertisingData),
52 for (
const auto &service: scanResponseData.
services()) {
79void QLeDBusAdvertiser::setDataForDBus()
81 setAdvertisingParamsForDBus();
82 setAdvertisementDataForDBus();
85void QLeDBusAdvertiser::setAdvertisingParamsForDBus()
89 qCWarning(QT_BT_BLUEZ) <<
"White lists and filter policies not supported, ignoring";
92 switch (m_advParams.
mode())
115void QLeDBusAdvertiser::setAdvertisementDataForDBus()
138 for (
const auto& service: m_advData.
services())
154 qCDebug(QT_BT_BLUEZ) <<
"Ignoring advertisement discoverability in broadcast mode";
159 qCWarning(QT_BT_BLUEZ) <<
"Raw advertisement data not supported, ignoring";
164 qCDebug(QT_BT_BLUEZ) <<
"Start advertising" << m_advObjectPath <<
"on" << m_advManager->
path();
166 qCWarning(QT_BT_BLUEZ) <<
"Start tried while already advertising";
172 qCWarning(QT_BT_BLUEZ) <<
"Advertisement dbus object registration failed";
186 if (
reply.isError()) {
187 qCWarning(QT_BT_BLUEZ) <<
"Advertisement registration failed" << reply.error();
188 if (reply.error().name() == bluezErrorFailed)
189 qCDebug(QT_BT_BLUEZ) <<
"Advertisement could've been too large";
190 QDBusConnection::systemBus().unregisterObject(m_advObjectPath);
191 emit errorOccurred();
193 qCDebug(QT_BT_BLUEZ) <<
"Advertisement started successfully";
194 m_advertising = true;
205 m_advertising =
false;
207 reply.waitForFinished();
211 qCDebug(QT_BT_BLUEZ) <<
"Advertisement unregistered successfully";
218 qCDebug(QT_BT_BLUEZ) <<
"Advertisement" << m_advObjectPath <<
"released"
219 << (m_advertising ?
"unexpectedly" :
"");
223 m_advertising =
false;
QString sanitizeNameForDBus(const QString &text)
std::vector< ObjCStrongReference< CBMutableService > > services
void setDiscoverable(bool value)
void setType(const QString &value)
void setManufacturerData(ManufacturerDataList value)
void setIncludes(const QStringList &value)
void setServiceUUIDs(const QStringList &value)
void setMinInterval(uint value)
void setMaxInterval(uint value)
void setLocalName(const QString &value)
QDBusPendingReply RegisterAdvertisement(const QDBusObjectPath &advertisement, const QVariantMap &options)
QDBusPendingReply UnregisterAdvertisement(const QDBusObjectPath &advertisement)
QStringList supportedIncludes() const
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QString path() const
Returns the object path that this interface is associated with.
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 finished(QDBusPendingCallWatcher *self=nullptr)
This signal is emitted when the pending call has finished and its reply is available.
Q_INVOKABLE void Release()
QLeDBusAdvertiser(const QLowEnergyAdvertisingParameters ¶ms, const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData, const QString &hostAdapterPath, QObject *parent=nullptr)
~QLeDBusAdvertiser() override
bool isEmpty() const noexcept
The QLowEnergyAdvertisingData class represents the data to be broadcast during Bluetooth Low Energy a...
QString localName() const
Returns the name of the local device that is to be advertised.
void setIncludePowerLevel(bool doInclude)
Specifies whether to include the device's transmit power level in the advertising data.
void setManufacturerData(quint16 id, const QByteArray &data)
Sets the manufacturer id and data.
QByteArray manufacturerData() const
Returns the manufacturer data.
QByteArray rawData() const
Returns the user-supplied raw data to be advertised.
bool includePowerLevel() const
Returns whether to include the device's transmit power level in the advertising data.
void setLocalName(const QString &name)
Specifies that name should be broadcast as the name of the device.
quint16 manufacturerId() const
Returns the manufacturer id.
Discoverability discoverability() const
Returns the discoverability mode of the advertising device.
QList< QBluetoothUuid > services() const
Returns the list of service UUIDs to be advertised.
void setServices(const QList< QBluetoothUuid > &services)
Specifies that the service UUIDs in services should be advertised.
static quint16 invalidManufacturerId()
Returns an invalid manufacturer id.
The QLowEnergyAdvertisingParameters class represents the parameters used for Bluetooth Low Energy adv...
Mode mode() const
Returns the advertising mode.
int minimumInterval() const
Returns the minimum advertising interval in milliseconds.
int maximumInterval() const
Returns the maximum advertising interval in milliseconds.
QList< AddressInfo > whiteList() const
Returns the white list used for filtering scan and connection requests.
NetworkError error() const
Returns the error that was found during the processing of this request.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QtJniTypes::Service service()
static constexpr auto advDataTypePeripheral
static constexpr quint16 advDataMaxIntervalMs
static constexpr auto advObjectPathTemplate
static constexpr quint16 advDataMinIntervalMs
static constexpr auto bluezErrorFailed
static constexpr auto bluezService
static constexpr auto advDataTXPower
static constexpr auto advDataTypeBroadcast
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qBound(const T &min, const T &val, const T &max)
QFutureWatcher< int > watcher
char * toString(const MyType &t)
[31]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent