![]() |
Qt 6.x
The Qt SDK
|
The QLowEnergyAdvertisingData class represents the data to be broadcast during Bluetooth Low Energy advertising. \inmodule QtBluetooth. More...
#include <qlowenergyadvertisingdata.h>
Public Types | |
enum | Discoverability { DiscoverabilityNone , DiscoverabilityLimited , DiscoverabilityGeneral } |
The discoverability of the advertising device as defined by the Generic Access Profile. More... | |
Public Member Functions | |
QLowEnergyAdvertisingData () | |
Creates a new object of this class. | |
QLowEnergyAdvertisingData (const QLowEnergyAdvertisingData &other) | |
Constructs a new object of this class that is a copy of other. | |
~QLowEnergyAdvertisingData () | |
Destroys this object. | |
QLowEnergyAdvertisingData & | operator= (const QLowEnergyAdvertisingData &other) |
Makes this object a copy of other and returns the new value of this object. | |
void | setLocalName (const QString &name) |
Specifies that name should be broadcast as the name of the device. | |
QString | localName () const |
Returns the name of the local device that is to be advertised. | |
void | setManufacturerData (quint16 id, const QByteArray &data) |
Sets the manufacturer id and data. | |
quint16 | manufacturerId () const |
Returns the manufacturer id. | |
QByteArray | manufacturerData () const |
Returns the manufacturer data. | |
void | setIncludePowerLevel (bool doInclude) |
Specifies whether to include the device's transmit power level in the advertising data. | |
bool | includePowerLevel () const |
Returns whether to include the device's transmit power level in the advertising data. | |
void | setDiscoverability (Discoverability mode) |
Sets the discoverability type of the advertising device to mode. | |
Discoverability | discoverability () const |
Returns the discoverability mode of the advertising device. | |
void | setServices (const QList< QBluetoothUuid > &services) |
Specifies that the service UUIDs in services should be advertised. | |
QList< QBluetoothUuid > | services () const |
Returns the list of service UUIDs to be advertised. | |
void | setRawData (const QByteArray &data) |
Sets the data to be advertised to data. | |
QByteArray | rawData () const |
Returns the user-supplied raw data to be advertised. | |
void | swap (QLowEnergyAdvertisingData &other) noexcept |
Swaps this object with other. | |
Static Public Member Functions | |
static quint16 | invalidManufacturerId () |
Returns an invalid manufacturer id. | |
Friends | |
bool | operator== (const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b) |
Returns true if data1 and data2 are equal with respect to their public state, otherwise returns false . | |
bool | operator!= (const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b) |
Returns true if data1 and data2 are not equal with respect to their public state, otherwise returns false . | |
The QLowEnergyAdvertisingData class represents the data to be broadcast during Bluetooth Low Energy advertising. \inmodule QtBluetooth.
This data can include the device name, GATT services offered by the device, and so on. The data set via this class will be used when advertising is started by calling \l QLowEnergyController::startAdvertising(). Objects of this class can represent an Advertising Data packet or a Scan Response packet.
Definition at line 15 of file qlowenergyadvertisingdata.h.
The discoverability of the advertising device as defined by the Generic Access Profile.
\value DiscoverabilityNone The advertising device does not wish to be discoverable by scanning devices. \value DiscoverabilityLimited The advertising device wishes to be discoverable with a high priority. Note that this mode is not compatible with using a white list. The value of \l QLowEnergyAdvertisingParameters::filterPolicy() is always assumed to be \l QLowEnergyAdvertisingParameters::IgnoreWhiteList when limited discoverability is used. \value DiscoverabilityGeneral The advertising device wishes to be discoverable by scanning devices.
Enumerator | |
---|---|
DiscoverabilityNone | |
DiscoverabilityLimited | |
DiscoverabilityGeneral |
Definition at line 43 of file qlowenergyadvertisingdata.h.
QLowEnergyAdvertisingData::QLowEnergyAdvertisingData | ( | ) |
Creates a new object of this class.
All values are initialized to their defaults according to the Bluetooth Low Energy specification.
Definition at line 74 of file qlowenergyadvertisingdata.cpp.
QLowEnergyAdvertisingData::QLowEnergyAdvertisingData | ( | const QLowEnergyAdvertisingData & | other | ) |
Constructs a new object of this class that is a copy of other.
Definition at line 79 of file qlowenergyadvertisingdata.cpp.
QLowEnergyAdvertisingData::~QLowEnergyAdvertisingData | ( | ) |
Destroys this object.
Definition at line 85 of file qlowenergyadvertisingdata.cpp.
QLowEnergyAdvertisingData::Discoverability QLowEnergyAdvertisingData::discoverability | ( | ) | const |
Returns the discoverability mode of the advertising device.
The default is \l DiscoverabilityNone.
Definition at line 184 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::discoverability.
bool QLowEnergyAdvertisingData::includePowerLevel | ( | ) | const |
Returns whether to include the device's transmit power level in the advertising data.
The default is false
.
Definition at line 164 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::includePowerLevel.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser(), and QLeAdvertiserBluez::doStartAdvertising().
|
inlinestatic |
Returns an invalid manufacturer id.
If this value is set as the manufacturer id (which it is by default), no manufacturer data will be present in the advertising data.
Definition at line 35 of file qlowenergyadvertisingdata.h.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
QString QLowEnergyAdvertisingData::localName | ( | ) | const |
Returns the name of the local device that is to be advertised.
Definition at line 118 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::localName.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
QByteArray QLowEnergyAdvertisingData::manufacturerData | ( | ) | const |
Returns the manufacturer data.
The default is an empty byte array.
Definition at line 146 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::manufacturerData.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
quint16 QLowEnergyAdvertisingData::manufacturerId | ( | ) | const |
Returns the manufacturer id.
The default is \l QLowEnergyAdvertisingData::invalidManufacturerId(), which means the data will not be advertised.
Definition at line 138 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::manufacturerId.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
QLowEnergyAdvertisingData & QLowEnergyAdvertisingData::operator= | ( | const QLowEnergyAdvertisingData & | other | ) |
Makes this object a copy of other and returns the new value of this object.
Definition at line 90 of file qlowenergyadvertisingdata.cpp.
References other().
QByteArray QLowEnergyAdvertisingData::rawData | ( | ) | const |
Returns the user-supplied raw data to be advertised.
The default is an empty byte array.
Definition at line 226 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::rawData.
QList< QBluetoothUuid > QLowEnergyAdvertisingData::services | ( | ) | const |
Returns the list of service UUIDs to be advertised.
By default, this list is empty.
Definition at line 203 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::services.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser(), and setServices().
void QLowEnergyAdvertisingData::setDiscoverability | ( | QLowEnergyAdvertisingData::Discoverability | mode | ) |
Sets the discoverability type of the advertising device to mode.
Definition at line 175 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::discoverability.
void QLowEnergyAdvertisingData::setIncludePowerLevel | ( | bool | doInclude | ) |
Specifies whether to include the device's transmit power level in the advertising data.
If doInclude is true
, the data will be included, otherwise it will not.
Definition at line 155 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::includePowerLevel.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
Specifies that name should be broadcast as the name of the device.
If the full name does not fit into the advertising data packet, an abbreviated name is sent, as described by the Bluetooth Low Energy specification.
On Android, the local name cannot be changed. Android always uses the device name. If this local name is not empty, the Android implementation includes the device name in the advertisement packet; otherwise the device name is omitted from the advertisement packet.
Definition at line 108 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::localName.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
void QLowEnergyAdvertisingData::setManufacturerData | ( | quint16 | id, |
const QByteArray & | data | ||
) |
Sets the manufacturer id and data.
The id parameter is a company identifier as assigned by the Bluetooth SIG. The data parameter is an arbitrary value.
Definition at line 127 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::manufacturerData, and QLowEnergyAdvertisingDataPrivate::manufacturerId.
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
void QLowEnergyAdvertisingData::setRawData | ( | const QByteArray & | data | ) |
Sets the data to be advertised to data.
If the value is not an empty byte array, it will be sent as-is as the advertising data and all other data in this object will be ignored. This can be used to send non-standard data.
Providing the raw advertising data is not supported on BlueZ DBus backend as BlueZ does not support it. This may change in a future release.
Definition at line 218 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::rawData.
void QLowEnergyAdvertisingData::setServices | ( | const QList< QBluetoothUuid > & | services | ) |
Specifies that the service UUIDs in services should be advertised.
If the entire list does not fit into the packet, an incomplete list is sent as specified by the Bluetooth Low Energy specification.
Definition at line 194 of file qlowenergyadvertisingdata.cpp.
References QLowEnergyAdvertisingDataPrivate::services, and services().
Referenced by QLeDBusAdvertiser::QLeDBusAdvertiser().
|
inlinenoexcept |
Swaps this object with other.
Definition at line 57 of file qlowenergyadvertisingdata.h.
|
friend |
Returns true
if data1 and data2 are not equal with respect to their public state, otherwise returns false
.
Definition at line 27 of file qlowenergyadvertisingdata.h.
|
friend |
Returns true
if data1 and data2 are equal with respect to their public state, otherwise returns false
.
Definition at line 23 of file qlowenergyadvertisingdata.h.