summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller.h
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-10-14 16:54:47 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-11-17 15:40:02 +0000
commita5f362af452555b5aaa4585be82053029e4b25c0 (patch)
treeeae7edea0537c8fe55226628fc3d5618741cf04f /src/bluetooth/qlowenergycontroller.h
parenteb59027d32c7904a129b16c786df1dc2097ab9c9 (diff)
Bluetooth: Introduce API for LE advertising.
And provide an implementation for BlueZ. Change-Id: I302aee7c43b77016d9e1e7a0d5bcbf00096abf76 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller.h')
-rw-r--r--src/bluetooth/qlowenergycontroller.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller.h b/src/bluetooth/qlowenergycontroller.h
index be729dda..66928da8 100644
--- a/src/bluetooth/qlowenergycontroller.h
+++ b/src/bluetooth/qlowenergycontroller.h
@@ -38,11 +38,14 @@
#include <QtBluetooth/QBluetoothAddress>
#include <QtBluetooth/QBluetoothDeviceInfo>
#include <QtBluetooth/QBluetoothUuid>
+#include <QtBluetooth/QLowEnergyAdvertisingData>
#include <QtBluetooth/QLowEnergyService>
QT_BEGIN_NAMESPACE
+class QLowEnergyAdvertisingParameters;
class QLowEnergyControllerPrivate;
+
class Q_BLUETOOTH_EXPORT QLowEnergyController : public QObject
{
Q_OBJECT
@@ -53,7 +56,8 @@ public:
UnknownRemoteDeviceError,
NetworkError,
InvalidBluetoothAdapterError,
- ConnectionError
+ ConnectionError,
+ AdvertisingError,
};
Q_ENUM(Error)
@@ -63,7 +67,8 @@ public:
ConnectedState,
DiscoveringState,
DiscoveredState,
- ClosingState
+ ClosingState,
+ AdvertisingState,
};
Q_ENUM(ControllerState)
@@ -73,6 +78,9 @@ public:
};
Q_ENUM(RemoteAddressType)
+ enum Role { CentralRole, PeripheralRole };
+ Q_ENUM(Role)
+
explicit QLowEnergyController(const QBluetoothAddress &remoteDevice,
QObject *parent = 0); // TODO Qt 6 remove ctor
explicit QLowEnergyController(const QBluetoothDeviceInfo &remoteDevice,
@@ -80,6 +88,11 @@ public:
explicit QLowEnergyController(const QBluetoothAddress &remoteDevice,
const QBluetoothAddress &localDevice,
QObject *parent = 0); // TODO Qt 6 remove ctor
+
+ static QLowEnergyController *createCentral(const QBluetoothDeviceInfo &remoteDevice,
+ QObject *parent = 0);
+ static QLowEnergyController *createPeripheral(QObject *parent = 0);
+
~QLowEnergyController();
QBluetoothAddress localAddress() const;
@@ -100,9 +113,16 @@ public:
QLowEnergyService *createServiceObject(
const QBluetoothUuid &service, QObject *parent = 0);
+ void startAdvertising(const QLowEnergyAdvertisingParameters &parameters,
+ const QLowEnergyAdvertisingData &advertisingData,
+ const QLowEnergyAdvertisingData &scanResponseData = QLowEnergyAdvertisingData());
+ void stopAdvertising();
+
Error error() const;
QString errorString() const;
+ Role role() const;
+
Q_SIGNALS:
void connected();
void disconnected();
@@ -113,6 +133,8 @@ Q_SIGNALS:
void discoveryFinished();
private:
+ explicit QLowEnergyController(QObject *parent = 0); // For the peripheral role.
+
Q_DECLARE_PRIVATE(QLowEnergyController)
QLowEnergyControllerPrivate *d_ptr;
};
@@ -122,5 +144,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QLowEnergyController::Error)
Q_DECLARE_METATYPE(QLowEnergyController::ControllerState)
Q_DECLARE_METATYPE(QLowEnergyController::RemoteAddressType)
+Q_DECLARE_METATYPE(QLowEnergyController::Role)
#endif // QLOWENERGYCONTROLLER_H