summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-27 13:14:11 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-02 14:40:06 +0200
commitb2933fee26c74164e7050bf01e16217ac5fbb55b (patch)
treedbccf16a6a42b943ab140666c7734cb6baa6c357 /src
parent3e0a4c2f12f21f805102b327fa899b3aa14e1355 (diff)
Merge BTLE service names into QBluetoothUuid::serviceClassToString()
Change-Id: I83a99666b8b16ae80ad7712785ee294cb340add1 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp22
-rw-r--r--src/bluetooth/qlowenergyserviceinfo.cpp50
-rw-r--r--src/bluetooth/qlowenergyserviceinfo_p.h2
3 files changed, 33 insertions, 41 deletions
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 18402bb1..730a58e3 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -667,6 +667,28 @@ QString QBluetoothUuid::serviceClassToString(QBluetoothUuid::ServiceClassUuid uu
case QBluetoothUuid::HDP: return QBluetoothServiceDiscoveryAgent::tr("Health Device");
case QBluetoothUuid::HDPSource: return QBluetoothServiceDiscoveryAgent::tr("Health Device Source");
case QBluetoothUuid::HDPSink: return QBluetoothServiceDiscoveryAgent::tr("Health Device Sink");
+ case QBluetoothUuid::GenericAccess: return QBluetoothServiceDiscoveryAgent::tr("Generic Access");
+ case QBluetoothUuid::GenericAttribute: return QBluetoothServiceDiscoveryAgent::tr("Generic Attribute");
+ case QBluetoothUuid::ImmediateAlert: return QBluetoothServiceDiscoveryAgent::tr("Immediate Alert");
+ case QBluetoothUuid::LinkLoss: return QBluetoothServiceDiscoveryAgent::tr("Link Loss");
+ case QBluetoothUuid::TxPower: return QBluetoothServiceDiscoveryAgent::tr("Tx Power");
+ case QBluetoothUuid::CurrentTimeService: return QBluetoothServiceDiscoveryAgent::tr("Current Time Service");
+ case QBluetoothUuid::ReferenceTimeUpdateService: return QBluetoothServiceDiscoveryAgent::tr("Reference Time Update Service");
+ case QBluetoothUuid::NextDSTChangeService: return QBluetoothServiceDiscoveryAgent::tr("Next DST Change Service");
+ case QBluetoothUuid::Glucose: return QBluetoothServiceDiscoveryAgent::tr("Glucose");
+ case QBluetoothUuid::HealthThermometer: return QBluetoothServiceDiscoveryAgent::tr("Health Thermometer");
+ case QBluetoothUuid::DeviceInformation: return QBluetoothServiceDiscoveryAgent::tr("Device Information");
+ case QBluetoothUuid::HeartRate: return QBluetoothServiceDiscoveryAgent::tr("Heart Rate");
+ case QBluetoothUuid::PhoneAlertStatusService: return QBluetoothServiceDiscoveryAgent::tr("Phone Alert Status Service");
+ case QBluetoothUuid::BatteryService: return QBluetoothServiceDiscoveryAgent::tr("Battery Service");
+ case QBluetoothUuid::BloodPressure: return QBluetoothServiceDiscoveryAgent::tr("Blood Pressure");
+ case QBluetoothUuid::AlertNotificationService: return QBluetoothServiceDiscoveryAgent::tr("Alert Notification Service");
+ case QBluetoothUuid::HumanInterfaceDevice: return QBluetoothServiceDiscoveryAgent::tr("Human Interface Device");
+ case QBluetoothUuid::ScanParameters: return QBluetoothServiceDiscoveryAgent::tr("Scan Parameters");
+ case QBluetoothUuid::RunningSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Running Speed and Cadance");
+ case QBluetoothUuid::CyclingSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Cycling Speed and Cadance");
+ case QBluetoothUuid::CyclingPower: return QBluetoothServiceDiscoveryAgent::tr("Cycling Power");
+ case QBluetoothUuid::LocationAndNavigation: return QBluetoothServiceDiscoveryAgent::tr("Location and Navigation");
default:
break;
}
diff --git a/src/bluetooth/qlowenergyserviceinfo.cpp b/src/bluetooth/qlowenergyserviceinfo.cpp
index 0d9b03df..ee6a9484 100644
--- a/src/bluetooth/qlowenergyserviceinfo.cpp
+++ b/src/bluetooth/qlowenergyserviceinfo.cpp
@@ -41,6 +41,7 @@
#include "qlowenergyserviceinfo.h"
#include "qlowenergyserviceinfo_p.h"
+#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
@@ -70,43 +71,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- Method for parsing the service name with given \a uuid.
- * \brief parseUuid
- * \param uuid
- * \return
- */
-QString parseUuid(const QBluetoothUuid &uuid)
-{
- static QHash<int, QString> uuidnames;
- if ( uuidnames.isEmpty() ) {
- uuidnames[0x1800] = QStringLiteral("Generic Access");
- uuidnames[0x1801] = QStringLiteral("Generic Attribute");
- uuidnames[0x1802] = QStringLiteral("ImmediateAlert");
- uuidnames[0x1803] = QStringLiteral("Link Loss");
- uuidnames[0x1804] = QStringLiteral("Tx Power");
- uuidnames[0x1805] = QStringLiteral("Current Time Service");
- uuidnames[0x1806] = QStringLiteral("Reference Time Update Service");
- uuidnames[0x1807] = QStringLiteral("Next DST Change Service");
- uuidnames[0x1808] = QStringLiteral("Glucose");
- uuidnames[0x1809] = QStringLiteral("Health Thermometer");
- uuidnames[0x180A] = QStringLiteral("Device Information");
- uuidnames[0x180D] = QStringLiteral("Heart Rate");
- uuidnames[0x180E] = QStringLiteral("Phone Alert Status Service");
- uuidnames[0x180F] = QStringLiteral("Battery Service");
- uuidnames[0x1810] = QStringLiteral("Blood Pressure");
- uuidnames[0x1811] = QStringLiteral("Alert Notification Service");
- uuidnames[0x1812] = QStringLiteral("Human Interface Device");
- uuidnames[0x1813] = QStringLiteral("Scan Parameters");
- uuidnames[0x1814] = QStringLiteral("Running Speed and Cadance");
- uuidnames[0x1816] = QStringLiteral("Cycling Speed and Cadance");
- uuidnames[0x1818] = QStringLiteral("Cycling Power");
- uuidnames[0x1819] = QStringLiteral("Location and Navigation");
- }
- QString name = uuidnames.value(uuid.toUInt16(), QStringLiteral("Unknown Service"));
- return name;
-}
-
-/*!
Construct a new QLowEnergyServiceInfo.
*/
QLowEnergyServiceInfo::QLowEnergyServiceInfo():
@@ -124,7 +88,6 @@ QLowEnergyServiceInfo::QLowEnergyServiceInfo(const QBluetoothUuid &uuid):
d_ptr(QSharedPointer<QLowEnergyServiceInfoPrivate>(new QLowEnergyServiceInfoPrivate))
{
d_ptr->uuid = QBluetoothUuid(uuid);
- d_ptr->serviceName = parseUuid(d_ptr->uuid);
}
/*!
@@ -169,7 +132,16 @@ QList<QLowEnergyCharacteristicInfo> QLowEnergyServiceInfo::characteristics() con
*/
QString QLowEnergyServiceInfo::serviceName() const
{
- return d_ptr->serviceName;
+ bool ok = false;
+ quint16 clsId = d_ptr->uuid.toUInt16(&ok);
+ if (ok) {
+ QBluetoothUuid::ServiceClassUuid id
+ = static_cast<QBluetoothUuid::ServiceClassUuid>(clsId);
+ return QBluetoothUuid::serviceClassToString(id);
+ }
+ return qApp ?
+ qApp->translate("QBluetoothServiceDiscoveryAgent", "Unknown service") :
+ QStringLiteral("Unknown Service");
}
/*!
diff --git a/src/bluetooth/qlowenergyserviceinfo_p.h b/src/bluetooth/qlowenergyserviceinfo_p.h
index 4dcee2f9..ecd84f4c 100644
--- a/src/bluetooth/qlowenergyserviceinfo_p.h
+++ b/src/bluetooth/qlowenergyserviceinfo_p.h
@@ -61,8 +61,6 @@ public:
QLowEnergyServiceInfoPrivate();
~QLowEnergyServiceInfoPrivate();
- QString serviceName;
-
QBluetoothUuid uuid;
QList<QLowEnergyCharacteristicInfo> characteristicList;