QLowEnergyServiceData Class

QLowEnergyServiceData 类用于设置 GATT 服务数据。更多

Header: #include <QLowEnergyServiceData>
qmake: QT += bluetooth

公共类型

enum ServiceType { ServiceTypePrimary, ServiceTypeSecondary }

公共函数

QLowEnergyServiceData()
QLowEnergyServiceData(const QLowEnergyServiceData &other)
~QLowEnergyServiceData()
void addCharacteristic(const QLowEnergyCharacteristicData &characteristic)
void addIncludedService(QLowEnergyService *service)
QList<QLowEnergyCharacteristicData> characteristics() const
QList<QLowEnergyService *> includedServices() const
bool isValid() const
void setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)
void setIncludedServices(const QList<QLowEnergyService *> &services)
void setType(QLowEnergyServiceData::ServiceType type)
void setUuid(const QBluetoothUuid &uuid)
void swap(QLowEnergyServiceData &other)
QLowEnergyServiceData::ServiceType type() const
QBluetoothUuid uuid() const
QLowEnergyServiceData &operator=(const QLowEnergyServiceData &other)
bool operator!=(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)
bool operator==(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)

详细说明

该类对象通过QLowEnergyController::addService() 向 GATT 服务器添加服务。

成员类型文档

enum QLowEnergyServiceData::ServiceType

关贸总协定服务类型。

常数说明
QLowEnergyServiceData::ServiceTypePrimary0x2800该服务是主要服务。
QLowEnergyServiceData::ServiceTypeSecondary0x2801该服务是辅助服务。次要服务由其他服务包含,以实现一些更高级别的功能。

成员函数文档

QLowEnergyServiceData::QLowEnergyServiceData()

创建本类的新无效对象。

QLowEnergyServiceData::QLowEnergyServiceData(const QLowEnergyServiceData &other)

构造一个本类的新对象,它是other 的副本。

[noexcept] QLowEnergyServiceData::~QLowEnergyServiceData()

销毁该对象。

void QLowEnergyServiceData::addCharacteristic(const QLowEnergyCharacteristicData &characteristic)

如果characteristic 有效,则将其添加到特征列表中。

另请参阅 setCharacteristics()。

void QLowEnergyServiceData::addIncludedService(QLowEnergyService *service)

service 添加到包含的服务列表中。service 对象必须是调用QLowEnergyController::addService 后返回的。这一要求可防止循环包含(蓝牙规范禁止循环包含),还有助于支持包含多个相同类型服务的用例。

另请参阅 setIncludedServices()。

QList<QLowEnergyCharacteristicData> QLowEnergyServiceData::characteristics() const

返回特征列表。

另请参阅 setCharacteristics()。

QList<QLowEnergyService *> QLowEnergyServiceData::includedServices() const

返回包含的服务列表。

另请参阅 setIncludedServices()。

bool QLowEnergyServiceData::isValid() const

如果该服务的 UUID 不为空,则返回true

void QLowEnergyServiceData::setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)

将特征列表设置为characteristics 。只考虑有效特征。

另请参阅 characteristics() 和addCharacteristic()。

void QLowEnergyServiceData::setIncludedServices(const QList<QLowEnergyService *> &services)

将包含的服务列表设置为services 。该列表中的所有对象必须是通过调用QLowEnergyController::addService 返回的。

另请参阅 includedServices() 和addIncludedService()。

void QLowEnergyServiceData::setType(QLowEnergyServiceData::ServiceType type)

将此服务的类型设置为type

另请参阅 type() 。

void QLowEnergyServiceData::setUuid(const QBluetoothUuid &uuid)

将此服务的 UUID 设置为uuid

另请参阅 uuid() 。

[noexcept] void QLowEnergyServiceData::swap(QLowEnergyServiceData &other)

将此对象与other 互换。

QLowEnergyServiceData::ServiceType QLowEnergyServiceData::type() const

返回此服务的类型。

另请参阅 setType()。

QBluetoothUuid QLowEnergyServiceData::uuid() const

返回此服务的 UUID。

另请参阅 setUuid()。

QLowEnergyServiceData &QLowEnergyServiceData::operator=(const QLowEnergyServiceData &other)

使该对象成为other 的副本,并返回该对象的新值。

相关非成员

bool operator!=(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)

如果ab 的公共状态不相等,则返回true ,否则返回false

bool operator==(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)

如果ab 的公共状态相等,则返回true ,否则返回false

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.