summaryrefslogtreecommitdiffstats
path: root/tests/bttestui/btlocaldevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bttestui/btlocaldevice.h')
-rw-r--r--tests/bttestui/btlocaldevice.h121
1 files changed, 81 insertions, 40 deletions
diff --git a/tests/bttestui/btlocaldevice.h b/tests/bttestui/btlocaldevice.h
index a6130b12..4e7a8223 100644
--- a/tests/bttestui/btlocaldevice.h
+++ b/tests/bttestui/btlocaldevice.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef BTLOCALDEVICE_H
#define BTLOCALDEVICE_H
@@ -35,6 +10,8 @@
#include <QtBluetooth/QBluetoothServer>
#include <QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include <QtBluetooth/QBluetoothSocket>
+#include <QtBluetooth/QLowEnergyController>
+#include <QtBluetooth/QLowEnergyServiceData>
class BtLocalDevice : public QObject
{
@@ -43,22 +20,37 @@ public:
explicit BtLocalDevice(QObject *parent = 0);
~BtLocalDevice();
Q_PROPERTY(QString hostMode READ hostMode NOTIFY hostModeStateChanged)
- Q_PROPERTY(int secFlags READ secFlags WRITE setSecFlags
- NOTIFY secFlagsChanged)
+ Q_PROPERTY(int secFlags READ secFlags WRITE setSecFlags NOTIFY secFlagsChanged)
- int secFlags() const;
+ Q_PROPERTY(bool centralExists READ centralExists NOTIFY leChanged);
+ Q_PROPERTY(bool centralSubscribed READ centralSubscribed NOTIFY leChanged);
+ Q_PROPERTY(QByteArray centralState READ centralState NOTIFY leChanged);
+ Q_PROPERTY(QByteArray centralError READ centralError NOTIFY leChanged);
+ Q_PROPERTY(QByteArray centralServiceState READ centralServiceState NOTIFY leChanged);
+ Q_PROPERTY(QByteArray centralServiceError READ centralServiceError NOTIFY leChanged);
+ Q_PROPERTY(QByteArray centralRSSI READ centralRSSI NOTIFY leChanged);
+
+ Q_PROPERTY(QByteArray peripheralState READ peripheralState NOTIFY leChanged);
+ Q_PROPERTY(QByteArray peripheralError READ peripheralError NOTIFY leChanged);
+ Q_PROPERTY(QByteArray peripheralServiceState READ peripheralServiceState NOTIFY leChanged);
+ Q_PROPERTY(QByteArray peripheralServiceError READ peripheralServiceError NOTIFY leChanged);
+ Q_PROPERTY(bool peripheralExists READ peripheralExists NOTIFY leChanged);
+
+ QBluetooth::SecurityFlags secFlags() const;
void setSecFlags(int);
QString hostMode() const;
signals:
- void error(QBluetoothLocalDevice::Error error);
+ void errorOccurred(QBluetoothLocalDevice::Error error);
void hostModeStateChanged();
void socketStateUpdate(int foobar);
void secFlagsChanged();
+ bool leChanged(); // Same signal used for LE changes for simplicity
public slots:
//QBluetoothLocalDevice
void dumpInformation();
+ void dumpErrors();
void powerOn();
void reset();
void setHostMode(int newMode);
@@ -66,13 +58,12 @@ public slots:
void pairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
void connected(const QBluetoothAddress &addr);
void disconnected(const QBluetoothAddress &addr);
- void pairingDisplayConfirmation(const QBluetoothAddress &address, const QString &pin);
- void pairingDisplayPinCode(const QBluetoothAddress &address, const QString &pin);
- void confirmPairing();
void cycleSecurityFlags();
//QBluetoothDeviceDiscoveryAgent
void deviceDiscovered(const QBluetoothDeviceInfo &info);
+ void deviceUpdated(const QBluetoothDeviceInfo &info,
+ QBluetoothDeviceInfo::Fields updateFields);
void discoveryFinished();
void discoveryCanceled();
void discoveryError(QBluetoothDeviceDiscoveryAgent::Error error);
@@ -113,19 +104,69 @@ public slots:
void clientSocketReadyRead();
void dumpServerInformation();
+ //QLowEnergyController central
+ void centralCreate();
+ void centralConnect();
+ void centralStartServiceDiscovery();
+ void centralDiscoverServiceDetails();
+ void centralCharacteristicWrite();
+ void centralCharacteristicRead();
+ void centralDescriptorWrite();
+ void centralDescriptorRead();
+ void centralSubscribeUnsubscribe();
+ void centralDelete();
+ void centralDisconnect();
+ bool centralExists() const;
+ bool centralSubscribed() const;
+ QByteArray centralState() const;
+ QByteArray centralServiceState() const;
+ QByteArray centralError() const;
+ QByteArray centralServiceError() const;
+ void centralReadRSSI() const;
+ QByteArray centralRSSI() const;
+
+ //QLowEnergyController peripheral
+ void peripheralCreate();
+ void peripheralAddServices();
+ void peripheralStartAdvertising();
+ void peripheralStopAdvertising();
+ void peripheralCharacteristicRead();
+ void peripheralCharacteristicWrite();
+ void peripheralDescriptorRead();
+ void peripheralDescriptorWrite();
+ void peripheralDelete();
+ void peripheralDisconnect();
+ bool peripheralExists() const;
+ QByteArray peripheralState() const;
+ QByteArray peripheralServiceState() const;
+ QByteArray peripheralError() const;
+ QByteArray peripheralServiceError() const;
+
+ // QLowEnergyController misc
+ void startLeDeviceDiscovery();
+ void dumpLeInfo();
+
private:
void dumpLocalDevice(QBluetoothLocalDevice *dev);
- QBluetoothLocalDevice *localDevice;
- QBluetoothDeviceDiscoveryAgent *deviceAgent;
- QBluetoothServiceDiscoveryAgent *serviceAgent;
- QBluetoothSocket *socket;
- QBluetoothServer *server;
+ QBluetoothLocalDevice *localDevice = nullptr;
+ QBluetoothDeviceDiscoveryAgent *deviceAgent = nullptr;
+ QBluetoothServiceDiscoveryAgent *serviceAgent = nullptr;
+ QBluetoothSocket *socket = nullptr;
+ QBluetoothServer *server = nullptr;
QList<QBluetoothSocket *> serverSockets;
QBluetoothServiceInfo serviceInfo;
-
QList<QBluetoothServiceInfo> foundTestServers;
QBluetooth::SecurityFlags securityFlags;
+
+ std::unique_ptr<QLowEnergyController> leCentralController;
+ std::unique_ptr<QLowEnergyController> lePeripheralController;
+ std::unique_ptr<QLowEnergyService> leCentralService;
+ QLowEnergyAdvertisingData leAdvertisingData;
+ QList<QLowEnergyServiceData> lePeripheralServiceData;
+ QList<QSharedPointer<QLowEnergyService>> lePeripheralServices;
+ QBluetoothDeviceInfo leRemotePeripheralDevice;
+ QByteArray latestRSSI = "N/A";
};
#endif // BTLOCALDEVICE_H