![]() |
Qt 6.x
The Qt SDK
|
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth. More...
#include <qlowenergyservicedata.h>
Public Types | |
enum | ServiceType { ServiceTypePrimary = 0x2800 , ServiceTypeSecondary = 0x2801 } |
The type of GATT service. More... | |
Public Member Functions | |
QLowEnergyServiceData () | |
Creates a new invalid object of this class. | |
QLowEnergyServiceData (const QLowEnergyServiceData &other) | |
Constructs a new object of this class that is a copy of other. | |
~QLowEnergyServiceData () | |
Destroys this object. | |
QLowEnergyServiceData & | operator= (const QLowEnergyServiceData &other) |
Makes this object a copy of other and returns the new value of this object. | |
ServiceType | type () const |
Returns the type of this service. | |
void | setType (ServiceType type) |
Sets the type of this service to type. | |
QBluetoothUuid | uuid () const |
Returns the UUID of this service. | |
void | setUuid (const QBluetoothUuid &uuid) |
Sets the UUID of this service to uuid. | |
QList< QLowEnergyService * > | includedServices () const |
Returns the list of included services. | |
void | setIncludedServices (const QList< QLowEnergyService * > &services) |
Sets the list of included services to services. | |
void | addIncludedService (QLowEnergyService *service) |
Adds service to the list of included services. | |
QList< QLowEnergyCharacteristicData > | characteristics () const |
Returns the list of characteristics. | |
void | setCharacteristics (const QList< QLowEnergyCharacteristicData > &characteristics) |
Sets the list of characteristics to characteristics. | |
void | addCharacteristic (const QLowEnergyCharacteristicData &characteristic) |
Adds characteristic to the list of characteristics, if it is valid. | |
bool | isValid () const |
Returns true if this service is has a non-null UUID. | |
void | swap (QLowEnergyServiceData &other) noexcept |
Swaps this object with other. | |
Friends | |
bool | operator== (const QLowEnergyServiceData &a, const QLowEnergyServiceData &b) |
Returns true if a and b are equal with respect to their public state, otherwise returns false . | |
bool | operator!= (const QLowEnergyServiceData &a, const QLowEnergyServiceData &b) |
Returns true if a and b are unequal with respect to their public state, otherwise returns false . | |
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
An Object of this class provides a service to be added to a GATT server via \l QLowEnergyController::addService().
Definition at line 17 of file qlowenergyservicedata.h.
The type of GATT service.
\value ServiceTypePrimary The service is a primary service. \value ServiceTypeSecondary The service is a secondary service. Secondary services are included by other services to implement some higher-level functionality.
Enumerator | |
---|---|
ServiceTypePrimary | |
ServiceTypeSecondary |
Definition at line 34 of file qlowenergyservicedata.h.
QLowEnergyServiceData::QLowEnergyServiceData | ( | ) |
Creates a new invalid object of this class.
Definition at line 48 of file qlowenergyservicedata.cpp.
QLowEnergyServiceData::QLowEnergyServiceData | ( | const QLowEnergyServiceData & | other | ) |
Constructs a new object of this class that is a copy of other.
Definition at line 53 of file qlowenergyservicedata.cpp.
QLowEnergyServiceData::~QLowEnergyServiceData | ( | ) |
Destroys this object.
Definition at line 58 of file qlowenergyservicedata.cpp.
void QLowEnergyServiceData::addCharacteristic | ( | const QLowEnergyCharacteristicData & | characteristic | ) |
Adds characteristic to the list of characteristics, if it is valid.
Definition at line 145 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::characteristics, QLowEnergyCharacteristicData::isValid(), and qCWarning.
Referenced by setCharacteristics().
void QLowEnergyServiceData::addIncludedService | ( | QLowEnergyService * | service | ) |
Adds service to the list of included services.
The service object must have been returned from a call to \l QLowEnergyController::addService. This requirement prevents circular includes (which are forbidden by the Bluetooth specification), and also helps to support the use case of including more than one service of the same type.
Definition at line 118 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::includedServices.
QList< QLowEnergyCharacteristicData > QLowEnergyServiceData::characteristics | ( | ) | const |
Returns the list of characteristics.
Definition at line 124 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::characteristics.
Referenced by QtBluezPeripheralApplication::addService(), QLowEnergyControllerPrivateAndroid::addToGenericAttributeList(), and setCharacteristics().
QList< QLowEnergyService * > QLowEnergyServiceData::includedServices | ( | ) | const |
Returns the list of included services.
Definition at line 94 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::includedServices.
Referenced by QtBluezPeripheralApplication::addService(), and QLowEnergyControllerPrivateAndroid::addToGenericAttributeList().
bool QLowEnergyServiceData::isValid | ( | ) | const |
Returns true
if this service is has a non-null UUID.
Definition at line 154 of file qlowenergyservicedata.cpp.
References QUuid::isNull(), and uuid().
QLowEnergyServiceData & QLowEnergyServiceData::operator= | ( | const QLowEnergyServiceData & | other | ) |
Makes this object a copy of other and returns the new value of this object.
Definition at line 63 of file qlowenergyservicedata.cpp.
References other().
void QLowEnergyServiceData::setCharacteristics | ( | const QList< QLowEnergyCharacteristicData > & | characteristics | ) |
Sets the list of characteristics to characteristics.
Only valid characteristics are considered.
Definition at line 134 of file qlowenergyservicedata.cpp.
References addCharacteristic(), QLowEnergyServiceDataPrivate::characteristics, characteristics(), and QList< T >::clear().
void QLowEnergyServiceData::setIncludedServices | ( | const QList< QLowEnergyService * > & | services | ) |
Sets the list of included services to services.
All objects in this list must have been returned from a call to \l QLowEnergyController::addService.
Definition at line 105 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::includedServices, and services.
void QLowEnergyServiceData::setType | ( | ServiceType | type | ) |
Sets the type of this service to type.
Definition at line 76 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::type, and type().
void QLowEnergyServiceData::setUuid | ( | const QBluetoothUuid & | uuid | ) |
Sets the UUID of this service to uuid.
Definition at line 88 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::uuid, and uuid().
|
inlinenoexcept |
Swaps this object with other.
Definition at line 51 of file qlowenergyservicedata.h.
QLowEnergyServiceData::ServiceType QLowEnergyServiceData::type | ( | ) | const |
Returns the type of this service.
Definition at line 70 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::type.
Referenced by QLowEnergyControllerPrivateAndroid::addToGenericAttributeList(), and setType().
QBluetoothUuid QLowEnergyServiceData::uuid | ( | ) | const |
Returns the UUID of this service.
Definition at line 82 of file qlowenergyservicedata.cpp.
References QLowEnergyServiceDataPrivate::uuid.
Referenced by isValid(), and setUuid().
|
friend |
Returns true
if a and b are unequal with respect to their public state, otherwise returns false
.
Definition at line 29 of file qlowenergyservicedata.h.
|
friend |
Returns true
if a and b are equal with respect to their public state, otherwise returns false
.
Definition at line 25 of file qlowenergyservicedata.h.