summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_osx_p.h
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-11-07 14:00:40 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-11-12 14:32:35 +0100
commit51dbe4a457c0bf81b96c898aab5d83b421e7a4f0 (patch)
treecc1c878a608c0d03ea7c67367548cc7b73322aa8 /src/bluetooth/qlowenergycontroller_osx_p.h
parentbe5883540fe61123da3fb39dd39cfd34eec442b8 (diff)
QLowEnergyController - connectTo/disconnectFrom/Device (OS X, iOS)
Implement connect to device/disconnect from device methods, add CentralManager class dealing with CBCentralManager (with additional external logic). - Improve error handling while in 'connecting' state. - Use the proper error (ConnectionError) instead of UnknownError + make the error handling more uniform while isConnecting == true. - Use isNull on QBluetoothUuid, no need in ugly 'hasUuid'. Change-Id: I84a704a746b4677ccb870b9c132db5f7359030c6 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_osx_p.h')
-rw-r--r--src/bluetooth/qlowenergycontroller_osx_p.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergycontroller_osx_p.h b/src/bluetooth/qlowenergycontroller_osx_p.h
index 6d48f591..4162c764 100644
--- a/src/bluetooth/qlowenergycontroller_osx_p.h
+++ b/src/bluetooth/qlowenergycontroller_osx_p.h
@@ -34,6 +34,7 @@
#ifndef QLOWENERGYCONTROLLER_OSX_P_H
#define QLOWENERGYCONTROLLER_OSX_P_H
+#include "osx/osxbtcentralmanager_p.h"
#include "qlowenergycontroller_p.h"
#include "qlowenergycontroller.h"
#include "osx/osxbtutility_p.h"
@@ -47,7 +48,8 @@
QT_BEGIN_NAMESPACE
// The suffix OSX is not the very right, it's also iOS.
-class QLowEnergyControllerPrivateOSX : public QLowEnergyControllerPrivate
+class QLowEnergyControllerPrivateOSX : public QLowEnergyControllerPrivate,
+ public OSXBluetooth::CentralManagerDelegate
{
friend class QLowEnergyController;
public:
@@ -59,12 +61,32 @@ public:
bool isValid() const;
private:
+ // CentralManagerDelegate:
+ void LEnotSupported() Q_DECL_OVERRIDE;
+ void connectSuccess() Q_DECL_OVERRIDE;
+
+ void serviceDiscoveryFinished(LEServices services) Q_DECL_OVERRIDE;
+ void includedServicesDiscoveryFinished(const QBluetoothUuid &serviceUuid,
+ LEServices services) Q_DECL_OVERRIDE;
+ void characteristicsDiscoveryFinished(const QBluetoothUuid &serviceUuid,
+ LECharacteristics characteristics) Q_DECL_OVERRIDE;
+ void disconnected() Q_DECL_OVERRIDE;
+ void error(QLowEnergyController::Error errorCode) Q_DECL_OVERRIDE;
+ void error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyController::Error errorCode) Q_DECL_OVERRIDE;
+
void connectToDevice();
void discoverServices();
void discoverServiceDetails(const QBluetoothUuid &serviceUuid);
QLowEnergyController *q_ptr;
QBluetoothUuid deviceUuid;
+ // To be sure we set controller's state correctly
+ // (Connecting or Connected) we have to know if we're
+ // still inside connectToDevice - this is important,
+ // if a peripheral is _already_ connected from Core Bluetooth's
+ // point of view.
+ bool isConnecting;
QString errorString;
QLowEnergyController::Error lastError;
@@ -75,6 +97,9 @@ private:
QLowEnergyController::ControllerState controllerState;
QLowEnergyController::RemoteAddressType addressType;
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCCentralManager> CentralManager;
+ CentralManager centralManager;
+
typedef QMap<QBluetoothUuid, QSharedPointer<QLowEnergyServicePrivate> > ServiceMap;
typedef ServiceMap::const_iterator ConstServiceIterator;
typedef ServiceMap::iterator ServiceIterator;