summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/osx/osxbtcentralmanager.mm
Commit message (Collapse)AuthorAgeFilesLines
* Enable macOS 10.13 in QtBluetoothAlex Blasche2017-08-311-4/+4
| | | | | | | | | A similar change was done earlier for iOS already. This is due to deprecated API. Task-number: QTBUG-62658 Change-Id: If1d4a0eae382e46e3224a6bd4a6e75309ff87cac Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* BTLE (CoreBluetooth) - prospective fixTimur Pocheptsov2017-07-161-6/+1
| | | | | | | | | | The type of manage.state has changed on macOS (like on iOS before), making an declataion invalid. (cherry-picked from qtconnectivity/0c3cc5374d2703fde6a99d301fcff974122d057d) Change-Id: I55caa32fa9f0a85090506cfbd788c1a80d41e8ce Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'gerrit/5.7' into 5.8v5.8.0-beta1Alex Blasche2016-10-121-0/+21
|\ | | | | | | | | | | | | | | Conflicts: src/bluetooth/osx/osxbtledeviceinquiry.mm src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm Change-Id: I7dc75c187af73917f31c28b9edfaf8bcf9652a3e
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-011-0/+21
| |\ | | | | | | | | | Change-Id: Ie9b0ebf1c5e925107e90b5d01b112916a8d1d83d
| | * Handle iOS 10 deprecated data structuresMike Krus2016-09-281-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | iOS 10 (and tvOS 10) deprecates CBCentralManagerState enum (and associated values). Replaced by CBManagerState enum. Change-Id: I1c1bb0691403deaa6330949516846961c76865f5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | | QtBluetooth - get rid of Q_FUNC_INFO (OS X/iOS)Timur Pocheptsov2016-06-021-45/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since now the use of Q_FUNC_INFO is not recommended (and indeed can mix ugly with QT_MESSAGE_PATTERN), remove it (it now stays only in 3-parameter Q_ASSERTs and NSLogs. The next patch will do the same kind of cleanup in C++ part. Change-Id: Ief8bd7c90ea2ff2a99f246885691102062aa5e54 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | QtBluetooth: remove outdate code (OS X/iOS)Timur Pocheptsov2016-06-021-78/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since we now have OS X 10.9 and iOS 7.0 as the minimal required (SDK and deployment target) - get rid of outdated code-branches in _SDK_EQUAL_OR_ABOVE etc. Change-Id: I5f546e8bb746f6b94f26a40460b3caa0af6a531c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-081-1/+1
|\| | | | | | | | | | | Change-Id: I858ee0b39b7a488f08fc045635d2a39053f32d99
| * | Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-beta1Liang Qi2016-04-081-1/+1
| |\| | | | | | | | | | Change-Id: I77d7b5877ce36057c3882a0b397ff27d5c35ad53
| | * OSXBTCentralManager - fix details discovery (iOS/OS X)Timur Pocheptsov2016-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | -serviceForUUID: fails to find included service and returns a nil for a valid service previously discovered. Task-number: QTBUG-52324 Change-Id: I9f4f8b1f3d3a78879344ace0170e23c03921d648 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | Add peripheral role (iOS/OS X).Timur Pocheptsov2016-03-131-27/+27
|/ / | | | | | | | | | | | | | | | | CoreBluetooth has CBPeripheralManager/CBMutableService both on iOS (since 6.0) and OS X (>= 10.9). This lets me implement the Qt's BTLE 'advertisement' API and peripheral role for both iOS and OS X. Change-Id: I3e69a5870535a45bc16bbd9862ca84300b01daca Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* | Updated license headersAntti Kokko2016-01-201-14/+20
| | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I856c13e2a6d4d12c46e1286b0ca1c092ee4608f8 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'gerrit/5.6' into devAlex Blasche2016-01-051-1/+0
|\| | | | | | | Change-Id: I97b51eb3fe2040711c00da67bbb1954fc2e65c1f
| * Fix namespaced build on OSX.Erik Verbruggen2015-12-231-2/+2
| | | | | | | | | | Change-Id: I0baa4bbbc5d398f388a1e0aff9ba88f82a23c1cc Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | tvOS supportMike Krus2016-01-051-2/+2
|/ | | | | | | | | | Builds but not tested Moved Q_DECLARE_METATYPE outside of namespace to fix namespaced builds Change-Id: I19c1dba904da8fad155f0f612b863e8f5e0c422e Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* qlowenergycontroller_osx - move delegate to the qt_LE_queueTimur Pocheptsov2015-12-101-192/+219
| | | | | | | | | | | | | | | | | | | | | | | | | ATM CBCentralManager's delegate does its work on the main queue. With CoreFoundation event dispatcher it's now possible to use QtBluetooth from non-gui thread (more generally - from a thread other than main). This makes main queue useless - and we have to move to a dedicated dispatch queue. Also, we have to make sure we do not have race conditioins/dead-locks. This patch: 1. decouples OSXBTLECentralManager and QLowEnergyController so that these two objects working (potentially) on different threads do not share any data and do not have to use locks, removes the explicit 'delegate' interface/inheritance and replaces them with LECentralNotifier class - to be able to use Qt's signal/slot mechanics for inter-thread communication. 2. all OSXBTLECentralManager's are now executed on qt_LE_queue queue to avoid any race-conditions (since they potentially update manager's internal state). 3. Results/errors are now reported using LECentralNotifier's object (QLowEnergyController has corresponding slots connected to the notifier) Task-number: QTBUG-49476 Change-Id: Ie07cdc13ad559c96a7d2ff010843fb7bcce07c99 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* CoreBluetooth - update for iOS 9.0Timur Pocheptsov2015-10-081-4/+15
| | | | | | | | | | | | | New SDK removed deprecated properties/methods and we have a compilation error as a result. Use performSelector instead of direct calls to make sure: 1. it compiles 2. it calls an existing method. Task-number:QTBUG-48518 Change-Id: I10a2d062f9e71229a1e218d9d167a4132b97b6ab Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bluetooth LE - add readCharacteristic/readDescriptor (OS X/iOS)Timur Pocheptsov2015-04-201-52/+191
| | | | | | | Add read descriptor/characteristic support for iOS and OS X. Change-Id: If7547f3756dc37930052c9cefd243d6063bcab1c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bluetooth - LE device discovery agent, timer bug (OS X)Timur Pocheptsov2015-03-241-6/+2
| | | | | | | | | | | | CBCentralManager does not have a timeout while scanning and we had to use a delayed selector (via performSelector) to interrupt the scan. This is a bug in the case we're in NSModalPanelRunLoopMode mode (for example) - selector never gets performed (it waits for the default mode) or performed too late. Found in our btchat example. Now we use external QTimer instead to check if it's time to stop a scan. Change-Id: I159bf5821398f3aa76f03a52a8334dea97cbf688 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-161-22/+14
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I3822a6484e8f7a420330de1cb1aeb0c3d1cf41b7 Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
* Qt Bluetooth - add runtime OS version check (OS X, iOS)Timur Pocheptsov2015-02-061-25/+29
| | | | | | | | Compile time check of SDK version is not sufficient if Qt is build for older device. Change-Id: I0e4d0baf903c6291e67462890107b0e5cc30e7c4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController/CentralManager - cleanup (OS X/iOS)Timur Pocheptsov2014-12-091-200/+120
| | | | | | | | | Get rid of all 'hand-written' function/method signatures in qCWarnings and Q_ASSERTS, use Q_FUNC_INFO instead. Fix error function for characteristic/descriptor write errors - remove unused parameter. Change-Id: I4f3f7c6c6a06802135f47a4b5cbb7c4313af4f34 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyConttroller - char/descriptor values (OS X/iOS)Timur Pocheptsov2014-12-081-73/+101
| | | | | | | | | | | | While writing with response, Core Bluetooth does not update characteristic/descriptor values in write notifications. I have to 'cache' this values and report them back. Also this patch fixes minor bugs in '-performNextWriteRequest': while handling errors it's not enough just to call 'performNextWriteRequest:' again, it must be in return statement or followed by 'return'. Change-Id: I6e7ab7fe6f63ea84268bf6c7ea67e2939d524f91 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - bug fixes (OS X, iOS)Timur Pocheptsov2014-12-081-12/+46
| | | | | | | | | | | | | | | | | | | | | | Several problems found by qlowenergycontroller auto test: - Core Bluetooth in its didWriteCharacteristicValue callback does not have this new updated value, but the old one, to avoid additional characteristic read I have to cache this value in writeCharacteristic and report it later from the callback as it's already done for client characteristic configuration. - writeDescriptor with state != ServiceDiscovered (can happen after disconnectFromDevice) should set an error. - setNotifyValue did not check that value has the wrong length ( > 2 bytes) - this also should be an error. - Fix a key mismatch - in setNotifyValue remember descrptor's handle, not the characteristic's handle. - Remove annoying qCWarnings from didUpdateNotifyValue - it happens very often that we set this value in 'automatic' mode, without 'writeDescriptor' request. Change-Id: If3955f0e1364587b96403d23f2f8da28e6723e87 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - remove debug messages (OS X, iOS)Timur Pocheptsov2014-12-051-3/+0
| | | | | | | Remove debug messages from OSXBTCentralManager. Change-Id: I980ffac49453b670fa93d4ddfb0e621e29dff4f3 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Client characteristic configuration (OS X and iOS)Timur Pocheptsov2014-12-051-0/+5
| | | | | | | | If client characteristic configuration descriptor has an indication/notification bit set - enable ("automatically" == no explicit user's request) notifications. Change-Id: I839aabd6f5513141f66c8e4467618b3edd523350 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyService - ClientCharacteristicConfigurationTimur Pocheptsov2014-12-031-19/+167
| | | | | | | | | Core Bluetooth has a special method to enable/disable char update notifications and even more - Core Bluetooth does not allow to use writeValue:forDescriptor: with ClientCharacteristicConfiguration - that's why need this 'workaround'. Change-Id: I4a01690a76aabf62397321ca6ba22c4abb1c420c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - concurrent characteristic writesTimur Pocheptsov2014-12-011-9/+52
| | | | | | | | | | Qt's API assumes that several write operations must be serialized (this is not guaranteed with Core Bluetooth AFAIK). I can enqueu only write with response operations, otherwise I never know when to do the next write. Change-Id: Iaa83514748358437e2c39335ab142d084ff197e3 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - writeDescriptor (OS X/iOS)Timur Pocheptsov2014-12-011-8/+109
| | | | | | | Core Bluetooth - based implementation. Change-Id: Ie642a13ae9a4d75401dd10648fac6eeee4123a3b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bluetooth LE - handles/chars/descriptors/services (OS X and iOS)Timur Pocheptsov2014-12-011-56/+120
| | | | | | | | | | | | | In Qt we work with handles (real for Bluez, emulated for Android/iOS/OS X). Core Bluetooth has its own (quite primitive and inconvenient) data structures (arrays of objects, containing nested arrays). To make things not so ugly I'm adding several maps to be able to find a characteristic/descriptor/service using a handle from Qt's layer. Also modify writeCharacteristic to use this new 'addressing scheme'. Change-Id: Ic822c9aa82a4df1e9c4cf4c673451cac8006b9ba Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyService::writeCharacteristic - implementation for OS X and iOSTimur Pocheptsov2014-11-261-0/+114
| | | | | | | writeCharacteristic - implemented with Core Bluetooth for OS X and iOS. Change-Id: Ia228ff451e1e6d7b6fb7de6cad29198aa9257602 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - service details discovery (OS X and iOS)Timur Pocheptsov2014-11-251-3/+446
| | | | | | | | | | Implement details discovery: characteristics, their values (if any), descriptors. We have to emulate handles (QLowEnergyHandle) - while Core Bluetooth internally has the notion of handles, it never exposes them as a public API. Change-Id: I09158433ce6835dd34fe8ad47d047212dab59e8e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - service discovery (OS X and iOS)Timur Pocheptsov2014-11-241-29/+110
| | | | | | | | | | | The initial version of service discovery failed to discover included services correctly, actually this discovery requires some kind of 'graph traversal' on the services tree. This patch re-implements the service discovery, discovering included services also and avoiding ... loops in services referencing each other (if it ever happens :) ) Change-Id: I60c6122fa5ddb922c21c99dd12024879cffad334 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - connectTo/disconnectFromDevice (OS X, iOS)Timur Pocheptsov2014-11-241-7/+8
| | | | | | | | | | | | | | | | | | | | Fix for disconnectFromDevice. It can happen that connect requesting is pending forever and not reporting any error: there is no timeout in Core Bluetooth (quite reasonable), a device (after it was found by LE scan) can be turned off or move out of range before connected. If a user calls disconnectFromDevice on a controller during this time: - we still have to call cancelPeripheralConnection to make sure the pending connection never succeeds - we have to set the controller's state to unconnected, since, unfortunately, delegate's callback is not guaranteed to work (descipe of Apple's docs promising this behavior). Fix for connectToDevice - small typo was breaking connectToDevice's logic. Change-Id: I4040c79a37ff31ecb5fb2296fa0d39b81d26393d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - service discovery (OS X, iOS)Timur Pocheptsov2014-11-131-1/+34
| | | | | | | | | | | Implement discoverServices and delegate's methods to work with a service discovery on a peripheral. - CBUUID (it's internal data) can be only 2 bytes long (16-bit shortened UUID) despite of the docs saying 'CBUUID is a 16-bit UUID'. - property 'isPrimary' did not exist prior to 10.9 SDK (OS X). Change-Id: If692d147c0479ed69a331514617e3ef2a986cdf4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - connectTo/disconnectFrom/Device (OS X, iOS)Timur Pocheptsov2014-11-121-0/+448
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>