summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-22 11:59:27 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-23 15:28:49 +0200
commit199bd8306541c3987cc4aae7d7f93af31717d3b5 (patch)
tree004d9a1a034d0abc39145b79d9c4b9edda4e6502 /examples/bluetooth/lowenergyscanner
parent58d1b5bdffc25f4ff22dcd00f0572c9c4fac3f88 (diff)
Detect secondary services and display service type in lowenergyscanner
QLowEnergyService::ServiceState was converted to a flag because a primary and secondary service can be included by other services. Change-Id: I425ce8e3f39ee07cccee2763b57a049a624f6178 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'examples/bluetooth/lowenergyscanner')
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Services.qml6
-rw-r--r--examples/bluetooth/lowenergyscanner/serviceinfo.cpp19
-rw-r--r--examples/bluetooth/lowenergyscanner/serviceinfo.h2
3 files changed, 27 insertions, 0 deletions
diff --git a/examples/bluetooth/lowenergyscanner/assets/Services.qml b/examples/bluetooth/lowenergyscanner/assets/Services.qml
index 361f14c1..e4e802d2 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Services.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Services.qml
@@ -108,6 +108,12 @@ Rectangle {
}
Label {
+ textContent: modelData.serviceType
+ font.pointSize: serviceName.font.pointSize * 0.5
+ anchors.top: serviceName.bottom
+ }
+
+ Label {
id: serviceUuid
font.pointSize: serviceName.font.pointSize * 0.5
textContent: modelData.serviceUuid
diff --git a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
index 19b99b9f..c05422ca 100644
--- a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
@@ -64,6 +64,25 @@ QString ServiceInfo::getName() const
return m_service->serviceName();
}
+QString ServiceInfo::getType() const
+{
+ if (!m_service)
+ return QString();
+
+ QString result;
+ if (m_service->type() & QLowEnergyService::PrimaryService)
+ result += QStringLiteral("primary");
+ else
+ result += QStringLiteral("secondary");
+
+ if (m_service->type() & QLowEnergyService::IncludedService)
+ result += QStringLiteral(" included");
+
+ result.prepend('<').append('>');
+
+ return result;
+}
+
QString ServiceInfo::getUuid() const
{
if (!m_service)
diff --git a/examples/bluetooth/lowenergyscanner/serviceinfo.h b/examples/bluetooth/lowenergyscanner/serviceinfo.h
index d02c79ba..1d35b1b7 100644
--- a/examples/bluetooth/lowenergyscanner/serviceinfo.h
+++ b/examples/bluetooth/lowenergyscanner/serviceinfo.h
@@ -48,12 +48,14 @@ class ServiceInfo: public QObject
Q_OBJECT
Q_PROPERTY(QString serviceName READ getName NOTIFY serviceChanged)
Q_PROPERTY(QString serviceUuid READ getUuid NOTIFY serviceChanged)
+ Q_PROPERTY(QString serviceType READ getType NOTIFY serviceChanged)
public:
ServiceInfo();
ServiceInfo(QLowEnergyService *service);
QLowEnergyService *service() const;
QString getUuid() const;
QString getName() const;
+ QString getType() const;
Q_SIGNALS:
void serviceChanged();