diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-10-26 16:36:17 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-11-03 13:08:57 +0000 |
commit | 202ec439d21456a318ed93c4bd1e6ba6f6460d59 (patch) | |
tree | e6e355fe284013be3934e475ddb151bf0f4916d6 /src/bluetooth/qlowenergycontroller_android_p.h | |
parent | e1c4f25ab12892baaf43b0476fe669a48b2c58d0 (diff) | |
download | qtconnectivity-202ec439d21456a318ed93c4bd1e6ba6f6460d59.tar.gz |
Provide own header for QLEControllerPrivate on Android
Change-Id: I63d107092e3e404f6b2c38f28d5d9b286711db77
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_android_p.h')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_android_p.h | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_android_p.h b/src/bluetooth/qlowenergycontroller_android_p.h new file mode 100644 index 00000000..ba56ad4c --- /dev/null +++ b/src/bluetooth/qlowenergycontroller_android_p.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QLOWENERGYCONTROLLERPRIVATEANDROID_P_H +#define QLOWENERGYCONTROLLERPRIVATEANDROID_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include <qglobal.h> +#include <QtCore/QQueue> +#include <QtCore/QVector> +#include <QtBluetooth/qbluetooth.h> +#include <QtBluetooth/qlowenergycharacteristic.h> +#include "qlowenergycontroller.h" +#include "qlowenergycontrollerbase_p.h" + +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) +#include <QtBluetooth/QBluetoothSocket> +#elif defined(QT_ANDROID_BLUETOOTH) +#include <QtAndroidExtras/QAndroidJniObject> +#include "android/lowenergynotificationhub_p.h" +#elif defined(QT_WINRT_BLUETOOTH) +#include <wrl.h> +#include <windows.devices.bluetooth.h> +#endif + +#include <functional> + +QT_BEGIN_NAMESPACE + +class QLowEnergyServiceData; +class QTimer; + +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) +class HciManager; +class LeCmacCalculator; +class QSocketNotifier; +class RemoteDeviceManager; +#elif defined(QT_ANDROID_BLUETOOTH) +class LowEnergyNotificationHub; +#elif defined(QT_WINRT_BLUETOOTH) +class QWinRTLowEnergyServiceHandler; +#endif + +extern void registerQLowEnergyControllerMetaType(); + +class QLeAdvertiser; + +class QLowEnergyControllerPrivateAndroid : public QLowEnergyControllerPrivate +{ + Q_OBJECT +public: + QLowEnergyControllerPrivateAndroid(); + ~QLowEnergyControllerPrivateAndroid(); + + void init() override; + + void connectToDevice() override; + void disconnectFromDevice() override; + + void discoverServices() override; + void discoverServiceDetails(const QBluetoothUuid &service) override; + + void startAdvertising(const QLowEnergyAdvertisingParameters ¶ms, + const QLowEnergyAdvertisingData &advertisingData, + const QLowEnergyAdvertisingData &scanResponseData) override; + void stopAdvertising() override; + + void requestConnectionUpdate(const QLowEnergyConnectionParameters ¶ms) override; + + // misc helpers + QLowEnergyService *addServiceHelper(const QLowEnergyServiceData &service) override; + + // read data + void readCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service, + const QLowEnergyHandle charHandle) override; + void readDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service, + const QLowEnergyHandle charHandle, + const QLowEnergyHandle descriptorHandle) override; + + // write data + void writeCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service, + const QLowEnergyHandle charHandle, + const QByteArray &newValue, QLowEnergyService::WriteMode mode) override; + void writeDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service, + const QLowEnergyHandle charHandle, + const QLowEnergyHandle descriptorHandle, + const QByteArray &newValue) override; + + void addToGenericAttributeList(const QLowEnergyServiceData &service, + QLowEnergyHandle startHandle) override; + + QLowEnergyHandle lastLocalHandle; +private: + + LowEnergyNotificationHub *hub; + +private slots: + void connectionUpdated(QLowEnergyController::ControllerState newState, + QLowEnergyController::Error errorCode); + void servicesDiscovered(QLowEnergyController::Error errorCode, + const QString &foundServices); + void serviceDetailsDiscoveryFinished(const QString& serviceUuid, + int startHandle, int endHandle); + void characteristicRead(const QBluetoothUuid &serviceUuid, int handle, + const QBluetoothUuid &charUuid, int properties, + const QByteArray& data); + void descriptorRead(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid, + int handle, const QBluetoothUuid &descUuid, const QByteArray &data); + void characteristicWritten(int charHandle, const QByteArray &data, + QLowEnergyService::ServiceError errorCode); + void descriptorWritten(int descHandle, const QByteArray &data, + QLowEnergyService::ServiceError errorCode); + void serverDescriptorWritten(const QAndroidJniObject &jniDesc, const QByteArray &newValue); + void characteristicChanged(int charHandle, const QByteArray &data); + void serverCharacteristicChanged(const QAndroidJniObject &jniChar, const QByteArray &newValue); + void serviceError(int attributeHandle, QLowEnergyService::ServiceError errorCode); + void advertisementError(int errorCode); + +private: + void peripheralConnectionUpdated(QLowEnergyController::ControllerState newState, + QLowEnergyController::Error errorCode); + void centralConnectionUpdated(QLowEnergyController::ControllerState newState, + QLowEnergyController::Error errorCode); +}; + +QT_END_NAMESPACE + +#endif // QLOWENERGYCONTROLLERPRIVATEANDROID_P_H |