diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-07-03 16:18:03 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-07-15 20:39:40 +0200 |
commit | c39189a922ce7057b410eba12e80abac589712cf (patch) | |
tree | 338815352496d1b1e2d0234f8fd81488e6dc84c5 /examples/bluetooth/lowenergyscanner/device.h | |
parent | 4a52ec355e2b2541d1867f785ef58c8c483b7316 (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/device.h')
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.h | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h index 3ac28c8f..053b04f1 100644 --- a/examples/bluetooth/lowenergyscanner/device.h +++ b/examples/bluetooth/lowenergyscanner/device.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the demonstration applications of the Qt Toolkit. @@ -48,23 +48,22 @@ #include <QList> #include <QBluetoothServiceDiscoveryAgent> #include <QBluetoothDeviceDiscoveryAgent> +#include <QLowEnergyControllerNew> +#include <QBluetoothServiceInfo> #include "deviceinfo.h" -#include "qlowenergycontroller.h" -#include "qlowenergyserviceinfo.h" #include "serviceinfo.h" #include "characteristicinfo.h" QT_FORWARD_DECLARE_CLASS (QBluetoothDeviceInfo) QT_FORWARD_DECLARE_CLASS (QLowEnergyServiceInfo) -QT_FORWARD_DECLARE_CLASS (QLowEnergyCharacteristicInfo) QT_FORWARD_DECLARE_CLASS (QBluetoothServiceInfo) class Device: public QObject { Q_OBJECT - Q_PROPERTY(QVariant devicesList READ getDevices NOTIFY devicesDone) - Q_PROPERTY(QVariant servicesList READ getServices NOTIFY servicesDone) - Q_PROPERTY(QVariant characteristicList READ getCharacteristics NOTIFY characteristicsDone) + Q_PROPERTY(QVariant devicesList READ getDevices NOTIFY devicesUpdated) + Q_PROPERTY(QVariant servicesList READ getServices NOTIFY servicesUpdated) + Q_PROPERTY(QVariant characteristicList READ getCharacteristics NOTIFY characteristicsUpdated) Q_PROPERTY(QString update READ getUpdate NOTIFY updateChanged) Q_PROPERTY(bool state READ state NOTIFY stateChanged) public: @@ -77,38 +76,45 @@ public: bool state(); public slots: - void addDevice(const QBluetoothDeviceInfo&); void startDeviceDiscovery(); - void scanFinished(); + void scanServices(const QString &address); + + void connectToService(const QString &uuid); + void disconnectFromDevice(); + +private slots: + // QBluetoothDeviceDiscoveryAgent related + void addDevice(const QBluetoothDeviceInfo&); + void deviceScanFinished(); void deviceScanError(QBluetoothDeviceDiscoveryAgent::Error); - void scanServices(QString address); - void addLowEnergyService(const QLowEnergyServiceInfo&); + + // QLowEnergyControllerNew realted + void addLowEnergyService(const QBluetoothUuid &uuid); + void deviceConnected(); + void errorReceived(QLowEnergyControllerNew::Error); void serviceScanDone(); - void serviceConnected(const QLowEnergyServiceInfo &service); - void connectToService(const QString &uuid); - void errorReceived(const QLowEnergyServiceInfo &service, QLowEnergyController::Error); - void disconnectFromService(); - void serviceDisconnected(const QLowEnergyServiceInfo &service); - void serviceScanError(QBluetoothServiceDiscoveryAgent::Error); + void deviceDisconnected(); + + // QLowEnergyService related + void serviceDetailsDiscovered(QLowEnergyService::ServiceState newState); Q_SIGNALS: - void devicesDone(); - void servicesDone(); - void characteristicsDone(); + void devicesUpdated(); + void servicesUpdated(); + void characteristicsUpdated(); void updateChanged(); void stateChanged(); private: void setUpdate(QString message); QBluetoothDeviceDiscoveryAgent *discoveryAgent; - QBluetoothServiceDiscoveryAgent *serviceDiscoveryAgent; DeviceInfo currentDevice; QList<QObject*> devices; QList<QObject*> m_services; QList<QObject*> m_characteristics; QString m_message; bool connected; - QLowEnergyController *info; + QLowEnergyControllerNew *controller; bool m_deviceScanState; }; |