diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-06-17 16:55:08 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-06-17 17:25:20 +0200 |
commit | 19714b30f9dff135f4b831895ce2ac518554e2c6 (patch) | |
tree | d4f5fbe1217ff167d3468f3d44f7d6267cf07f05 /src/bluetooth/qlowenergyservice.cpp | |
parent | 50e7588d6d2b4a21b2c4aebc0417b5cfcd8a9c03 (diff) |
Push improved API.
QLowEnergyService represents each single service on the remote BTLE
device. QLowEnergyControllerNew acts as factory for QLowEnergyService
instances.
Change-Id: I07c6bfae6d14b73a80e8314f6e8471285fccf069
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/bluetooth/qlowenergyservice.cpp')
-rw-r--r-- | src/bluetooth/qlowenergyservice.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp new file mode 100644 index 00000000..e60f7cc1 --- /dev/null +++ b/src/bluetooth/qlowenergyservice.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QCoreApplication> +#include <QtBluetooth/QLowEnergyService> +#include <QtBluetooth/QLowEnergyCharacteristicInfo> + +QT_BEGIN_NAMESPACE + +class QLowEnergyServicePrivate { +public: + QBluetoothUuid uuid; + QLowEnergyService::ServiceType type; + QLowEnergyService::ServiceState state; +}; + +QLowEnergyService::QLowEnergyService(const QBluetoothUuid &uuid, + QObject *parent) + : QObject(parent) +{ + d_ptr = new QLowEnergyServicePrivate(); + d_ptr->uuid = uuid; + d_ptr->state = QLowEnergyService::DiscoveryRequired; + d_ptr->type = QLowEnergyService::PrimaryService; +} + +QLowEnergyService::~QLowEnergyService() +{ + delete d_ptr; +} + +QList<QSharedPointer<QLowEnergyService> > QLowEnergyService::includedServices() const +{ + QList<QSharedPointer<QLowEnergyService > > results; + //TODO implement secondary service support + return results; +} + +QLowEnergyService::ServiceState QLowEnergyService::state() const +{ + return d_ptr->state; +} + + +QLowEnergyService::ServiceType QLowEnergyService::type() const +{ + return d_ptr->type; +} + + +QList<QLowEnergyCharacteristicInfo> QLowEnergyService::characteristics() const +{ + //TODO implement + QList<QLowEnergyCharacteristicInfo> results; + return results; +} + + +QBluetoothUuid QLowEnergyService::serviceUuid() const +{ + return d_ptr->uuid; +} + + +QString QLowEnergyService::serviceName() const +{ + 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"); +} + + +void QLowEnergyService::discoverDetails() +{ + //TODO discoverDetails +} + + +QT_END_NAMESPACE |