summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-03 16:18:03 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-15 20:39:40 +0200
commitc39189a922ce7057b410eba12e80abac589712cf (patch)
tree338815352496d1b1e2d0234f8fd81488e6dc84c5 /examples/bluetooth/lowenergyscanner/serviceinfo.cpp
parent4a52ec355e2b2541d1867f785ef58c8c483b7316 (diff)
Port lowenergyscanner example to new API
Some minor improvements have been incorporated too but the focus is on the port. More code and UI cleanups are required. Change-Id: I56f226b8418b78190d498df04d67686220a3644e Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'examples/bluetooth/lowenergyscanner/serviceinfo.cpp')
-rw-r--r--examples/bluetooth/lowenergyscanner/serviceinfo.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
index 1028fb40..19b99b9f 100644
--- a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
@@ -40,29 +41,43 @@
#include "serviceinfo.h"
-ServiceInfo::ServiceInfo():
- m_serviceLe(QLowEnergyServiceInfo())
+ServiceInfo::ServiceInfo()
{
-
}
-ServiceInfo::ServiceInfo(const QLowEnergyServiceInfo &service):
- m_serviceLe(service)
+ServiceInfo::ServiceInfo(QLowEnergyService *service):
+ m_service(service)
{
-
+ m_service->setParent(this);
}
-QLowEnergyServiceInfo ServiceInfo::getLeService() const
+QLowEnergyService *ServiceInfo::service() const
{
- return m_serviceLe;
+ return m_service;
}
QString ServiceInfo::getName() const
{
- return m_serviceLe.serviceName();
+ if (!m_service)
+ return QString();
+
+ return m_service->serviceName();
}
QString ServiceInfo::getUuid() const
{
- return m_serviceLe.serviceUuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
+ if (!m_service)
+ return QString();
+
+ const QBluetoothUuid uuid = m_service->serviceUuid();
+ bool success = false;
+ quint16 result16 = uuid.toUInt16(&success);
+ if (success)
+ return QStringLiteral("0x") + QString::number(result16, 16);
+
+ quint32 result32 = uuid.toUInt32(&success);
+ if (success)
+ return QStringLiteral("0x") + QString::number(result32, 16);
+
+ return uuid.toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
}