summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2021-02-26 14:54:33 +0100
committerAndreas Buhr <andreas@andreasbuhr.de>2021-03-11 13:01:51 +0100
commit66bb9839dbccea311cbb85168da86fb6d4a2d136 (patch)
treec9b535e4de503c0a2e0f998203bb6f94fcddf3ce /examples
parent61e2bab1d06f3f460f382f911bfd23edaef124e7 (diff)
Use scoped enum for constants in QBluetoothUuid
QBluetoothUuid contains enums for ProtocolUuid, ServiceClassUuid, CharacteristicType and DescriptorType. So far, they all put their constants directly into the QBluetoothUuid namespace, making it easy to mix them up. This patch changes those to scoped enums. That way, each enum has its items in its own namespace. Change-Id: I86ea08ff31009dc8073d84cfe678e27920d693f7 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/bluetooth/btchat/chatserver.cpp10
-rw-r--r--examples/bluetooth/heartrate-game/devicehandler.cpp10
-rw-r--r--examples/bluetooth/heartrate-server/main.cpp10
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp2
-rw-r--r--examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc2
5 files changed, 17 insertions, 17 deletions
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp
index ba7323d3..dfcaf925 100644
--- a/examples/bluetooth/btchat/chatserver.cpp
+++ b/examples/bluetooth/btchat/chatserver.cpp
@@ -87,7 +87,7 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter)
QBluetoothServiceInfo::Sequence profileSequence;
QBluetoothServiceInfo::Sequence classId;
- classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
classId << QVariant::fromValue(quint16(0x100));
profileSequence.append(QVariant::fromValue(classId));
serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,
@@ -95,7 +95,7 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter)
classId.clear();
classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
- classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
@@ -112,7 +112,7 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter)
//! [Service Discoverability]
QBluetoothServiceInfo::Sequence publicBrowse;
- publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+ publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::PublicBrowseGroup));
serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
publicBrowse);
//! [Service Discoverability]
@@ -120,10 +120,10 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter)
//! [Protocol descriptor list]
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
- protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ProtocolUuid::L2cap));
protocolDescriptorList.append(QVariant::fromValue(protocol));
protocol.clear();
- protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ProtocolUuid::Rfcomm))
<< QVariant::fromValue(quint8(rfcommServer->serverPort()));
protocolDescriptorList.append(QVariant::fromValue(protocol));
serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp
index a3937738..96d93044 100644
--- a/examples/bluetooth/heartrate-game/devicehandler.cpp
+++ b/examples/bluetooth/heartrate-game/devicehandler.cpp
@@ -164,7 +164,7 @@ void DeviceHandler::stopMeasurement()
//! [Filter HeartRate service 1]
void DeviceHandler::serviceDiscovered(const QBluetoothUuid &gatt)
{
- if (gatt == QBluetoothUuid(QBluetoothUuid::HeartRate)) {
+ if (gatt == QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::HeartRate)) {
setInfo("Heart Rate service discovered. Waiting for service scan to be done...");
m_foundHeartRateService = true;
}
@@ -184,7 +184,7 @@ void DeviceHandler::serviceScanDone()
//! [Filter HeartRate service 2]
// If heartRateService found, create new service
if (m_foundHeartRateService)
- m_service = m_control->createServiceObject(QBluetoothUuid(QBluetoothUuid::HeartRate), this);
+ m_service = m_control->createServiceObject(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::HeartRate), this);
if (m_service) {
connect(m_service, &QLowEnergyService::stateChanged, this, &DeviceHandler::serviceStateChanged);
@@ -209,13 +209,13 @@ void DeviceHandler::serviceStateChanged(QLowEnergyService::ServiceState s)
{
setInfo(tr("Service discovered."));
- const QLowEnergyCharacteristic hrChar = m_service->characteristic(QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement));
+ const QLowEnergyCharacteristic hrChar = m_service->characteristic(QBluetoothUuid(QBluetoothUuid::CharacteristicType::HeartRateMeasurement));
if (!hrChar.isValid()) {
setError("HR Data not found.");
break;
}
- m_notificationDesc = hrChar.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
+ m_notificationDesc = hrChar.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
if (m_notificationDesc.isValid())
m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100"));
@@ -234,7 +234,7 @@ void DeviceHandler::serviceStateChanged(QLowEnergyService::ServiceState s)
void DeviceHandler::updateHeartRateValue(const QLowEnergyCharacteristic &c, const QByteArray &value)
{
// ignore any other characteristic change -> shouldn't really happen though
- if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement))
+ if (c.uuid() != QBluetoothUuid(QBluetoothUuid::CharacteristicType::HeartRateMeasurement))
return;
auto data = reinterpret_cast<const quint8 *>(value.constData());
diff --git a/examples/bluetooth/heartrate-server/main.cpp b/examples/bluetooth/heartrate-server/main.cpp
index 426256fe..286125e5 100644
--- a/examples/bluetooth/heartrate-server/main.cpp
+++ b/examples/bluetooth/heartrate-server/main.cpp
@@ -81,21 +81,21 @@ int main(int argc, char *argv[])
advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
advertisingData.setIncludePowerLevel(true);
advertisingData.setLocalName("HeartRateServer");
- advertisingData.setServices(QList<QBluetoothUuid>() << QBluetoothUuid::HeartRate);
+ advertisingData.setServices(QList<QBluetoothUuid>() << QBluetoothUuid::ServiceClassUuid::HeartRate);
//! [Advertising Data]
//! [Service Data]
QLowEnergyCharacteristicData charData;
- charData.setUuid(QBluetoothUuid::HeartRateMeasurement);
+ charData.setUuid(QBluetoothUuid::CharacteristicType::HeartRateMeasurement);
charData.setValue(QByteArray(2, 0));
charData.setProperties(QLowEnergyCharacteristic::Notify);
- const QLowEnergyDescriptorData clientConfig(QBluetoothUuid::ClientCharacteristicConfiguration,
+ const QLowEnergyDescriptorData clientConfig(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration,
QByteArray(2, 0));
charData.addDescriptor(clientConfig);
QLowEnergyServiceData serviceData;
serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary);
- serviceData.setUuid(QBluetoothUuid::HeartRate);
+ serviceData.setUuid(QBluetoothUuid::ServiceClassUuid::HeartRate);
serviceData.addCharacteristic(charData);
//! [Service Data]
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
value.append(char(0)); // Flags that specify the format of the value.
value.append(char(currentHeartRate)); // Actual value.
QLowEnergyCharacteristic characteristic
- = service->characteristic(QBluetoothUuid::HeartRateMeasurement);
+ = service->characteristic(QBluetoothUuid::CharacteristicType::HeartRateMeasurement);
Q_ASSERT(characteristic.isValid());
service->writeCharacteristic(characteristic, value); // Potentially causes notification.
if (currentHeartRate == 60)
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
index 2402f4d1..61cfa044 100644
--- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
@@ -74,7 +74,7 @@ QString CharacteristicInfo::getName() const
// find descriptor with CharacteristicUserDescription
const QList<QLowEnergyDescriptor> descriptors = m_characteristic.descriptors();
for (const QLowEnergyDescriptor &descriptor : descriptors) {
- if (descriptor.type() == QBluetoothUuid::CharacteristicUserDescription) {
+ if (descriptor.type() == QBluetoothUuid::DescriptorType::CharacteristicUserDescription) {
name = descriptor.value();
break;
}
diff --git a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
index a7d48de6..7df08b2c 100644
--- a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
+++ b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
@@ -132,7 +132,7 @@
Although the example application does not display descriptors it uses descriptors to
get the name of an individual characteristic if its name cannot be discerned based on its
UUID. The second way to obtain the name is the existence of a descriptor of the type
- \l {QBluetoothUuid::CharacteristicUserDescription}. The code below demonstrates how this
+ \l {QBluetoothUuid::DescriptorType::CharacteristicUserDescription}. The code below demonstrates how this
may be achieved:
\snippet lowenergyscanner/characteristicinfo.cpp les-get-descriptors