summaryrefslogtreecommitdiff
path: root/src/bluetooth/osx/osxbtcentralmanagerdelegate.mm
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-10-15 17:15:23 +0200
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-11-06 16:25:43 +0100
commitf98a81839db4f3932038b4aded73782641958672 (patch)
tree886822f3216595b6f1b54cd91fbb35e1b3709cd8 /src/bluetooth/osx/osxbtcentralmanagerdelegate.mm
parentc7a1622d1f76bc61f0d5bb524d3eb40501cab13b (diff)
downloadqtconnectivity-f98a81839db4f3932038b4aded73782641958672.tar.gz
Bluetooth LE - device discovery for OS X.
- Unfortunately IOBluetoothDeviceInquiry does not scan for LE devices, so I need a separate scan for OS X and iOS imeplemented with CoreBluetooth framework. - CoreBluetooth hides addresses - "think different" in action. So we'll have to use 'identifiers' (NSUUID actually) provided by CoreBluetooth instead and we'll have to ask CBCentralManager to retrieve peripheral with a given NSUUID (or however we encode it). - Inform a delegate about LE device discovered. - Add the second scan/pass (Bluetooth LE) in QBluetoothDeviceDiscoveryAgent. - Make it all more "protocol conformant" - Do a proper cleanup + fix auto-test failure - Make a device inquiry longer + remove totally useless (??) 'name update'. - Use a plain bool instead of IOReturn (no this type(??) on iOS). - CoreBluetooth provides enumerators to check if LE is supported or not, no need to manipulate with StatePowerOn and other flags. - Add a workaround for a broken SDK (10.9 + CoreBluetooth headers + c++11). NSUUID is quite new - added in 10.8/6.0, works only on 10.9 and 7.0 (works == there is required interface). - CBCentralManager: it looks like it's impossible to delete an object of this type before centralDidUpdateStatus was called - this is not good, since a C++ object (the owner) can be deleted at any point - some preliminary workaround is to create a temporary delegate and pass the ownership from the dealloc. To be investigated/tested. - Move the TransientCentralManagerDelegate into the separate file - it'll be reused in future by other users of CBCentralManager. Change-Id: I4434c23366618061029be4022cfa0f7647df45b9 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/osx/osxbtcentralmanagerdelegate.mm')
-rw-r--r--src/bluetooth/osx/osxbtcentralmanagerdelegate.mm68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanagerdelegate.mm b/src/bluetooth/osx/osxbtcentralmanagerdelegate.mm
new file mode 100644
index 00000000..c0735d53
--- /dev/null
+++ b/src/bluetooth/osx/osxbtcentralmanagerdelegate.mm
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtcentralmanagerdelegate_p.h"
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTCentralManagerTransientDelegate)
+
+- (id)initWithManager:(CBCentralManager *)aManager
+{
+ if (self = [super init])
+ manager = aManager;
+
+ return self;
+}
+
+- (void)centralManagerDidUpdateState:(CBCentralManager *)central
+{
+ Q_UNUSED(central)
+
+ [self performSelectorOnMainThread:@selector(cleanup) withObject:nil waitUntilDone:NO];
+}
+
+- (void)cleanup
+{
+ [manager setDelegate:nil];
+ [manager release];
+ [self release];
+}
+
+@end