QLowEnergyAdvertisingData Class▲
-
Header: QLowEnergyAdvertisingData
-
Since: Qt 5.7
-
qmake: QT += bluetooth
-
Group: QLowEnergyAdvertisingData is part of shared
Detailed Description▲
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 QLowEnergyController::startAdvertising(). Objects of this class can represent an Advertising Data packet or a Scan Response packet.
The actual data packets sent over the advertising channel cannot contain more than 31 bytes. If the variable-length data set via this class exceeds that limit, it will be left out of the packet or truncated, depending on the type. On Android, advertising will fail if advertising data is larger than 31 bytes.
See Also▲
Member Type Documentation▲
enum QLowEnergyAdvertisingData::Discoverability▲
The discoverability of the advertising device as defined by the Generic Access Profile.
Constant |
Value |
Description |
---|---|---|
QLowEnergyAdvertisingData::DiscoverabilityNone |
0 |
The advertising device does not wish to be discoverable by scanning devices. |
QLowEnergyAdvertisingData::DiscoverabilityLimited |
1 |
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 QLowEnergyAdvertisingParameters::filterPolicy() is always assumed to be QLowEnergyAdvertisingParameters::IgnoreWhiteList when limited discoverability is used. |
QLowEnergyAdvertisingData::DiscoverabilityGeneral |
2 |
The advertising device wishes to be discoverable by scanning devices. |
Member Function Documentation▲
QLowEnergyAdvertisingData::QLowEnergyAdvertisingData()▲
Creates a new object of this class. All values are initialized to their defaults according to the Bluetooth Low Energy specification.
QLowEnergyAdvertisingData::QLowEnergyAdvertisingData(const QLowEnergyAdvertisingData &other)▲
Constructs a new object of this class that is a copy of other.
QLowEnergyAdvertisingData::~QLowEnergyAdvertisingData()▲
Destroys this object.
QLowEnergyAdvertisingData::Discoverability QLowEnergyAdvertisingData::discoverability() const▲
Returns the discoverability mode of the advertising device. The default is DiscoverabilityNone.
See Also▲
See also setDiscoverability()
bool QLowEnergyAdvertisingData::includePowerLevel() const▲
Returns whether to include the device's transmit power level in the advertising data. The default is false.
See Also▲
See also setIncludePowerLevel()
[static] quint16 QLowEnergyAdvertisingData::invalidManufacturerId()▲
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.
QString QLowEnergyAdvertisingData::localName() const▲
QByteArray QLowEnergyAdvertisingData::manufacturerData() const▲
Returns the manufacturer data. The default is an empty byte array.
See Also▲
See also setManufacturerData()
quint16 QLowEnergyAdvertisingData::manufacturerId() const▲
Returns the manufacturer id. The default is QLowEnergyAdvertisingData::invalidManufacturerId(), which means the data will not be advertised.
QByteArray QLowEnergyAdvertisingData::rawData() const▲
Returns the user-supplied raw data to be advertised. The default is an empty byte array.
See Also▲
See also setRawData()
QList<QBluetoothUuid> QLowEnergyAdvertisingData::services() const▲
Returns the list of service UUIDs to be advertised. By default, this list is empty.
See Also▲
See also setServices()
void QLowEnergyAdvertisingData::setDiscoverability(QLowEnergyAdvertisingData::Discoverability mode)▲
Sets the discoverability type of the advertising device to mode.
Discoverability information can only appear in an actual advertising data packet. If this object acts as scan response data, a call to this function will have no effect on the scan response sent.
See Also▲
See also 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.
See Also▲
See also includePowerLevel()
void QLowEnergyAdvertisingData::setLocalName(const QString &name)▲
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.
See Also▲
See also localName()
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.
See Also▲
See also manufacturerData()
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.
If data is longer than 31 bytes, it will be truncated. It is the caller's responsibility to ensure that data is well-formed.
See Also▲
See also 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.
See Also▲
See also services()
void QLowEnergyAdvertisingData::swap(QLowEnergyAdvertisingData &other)▲
Swaps this object with other.
QLowEnergyAdvertisingData &QLowEnergyAdvertisingData::operator=(const QLowEnergyAdvertisingData &other)▲
Makes this object a copy of other and returns the new value of this object.
Related Non-Members▲
bool operator!=(const QLowEnergyAdvertisingData &data1, const QLowEnergyAdvertisingData &data2)▲
Returns true if data1 and data2 are not equal with respect to their public state, otherwise returns false.
bool operator==(const QLowEnergyAdvertisingData &data1, const QLowEnergyAdvertisingData &data2)▲
Returns true if data1 and data2 are equal with respect to their public state, otherwise returns false.