summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_osx.mm
Commit message (Collapse)AuthorAgeFilesLines
* disconnectFromDevice now stops advertisement in peripheral roleTimur Pocheptsov2017-01-051-4/+6
| | | | | | | | | | The only thing we can do on macOS/iOS - call stopAdvertising (we have nothing to disconnect from with CoreBluetooth). Also, remove a really weird warning. Change-Id: I589bdb819468fc659a9ed3e68170dc498ffc8cd9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* LE controller - add a getter for a remote device UUIDTimur Pocheptsov2016-11-231-0/+7
| | | | | | | | | | | | A device UUID is valid/works on iOS/macOS only: platforms where CoreBluetooth hides addresses and generates 128-bit uuids instead. We connect to a LE device using such a UUID. This patch adds a getter to access a UUID of a remote device our controller works with (similar to 'remoteAddress' method on other platforms). Task-number: QTBUG-52690 Change-Id: I000e17bbea90c508922ac47ce5291e28d938de7c Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Emit descriptorWritten for notification/indication enabled/disabledTimur Pocheptsov2016-11-091-1/+46
| | | | | | | | | | | | From CoreBluetooth's point of view - this is just a callback, not a descriptor write request (they even consider all descriptors immutable in peripheral), but for Qt it should be a descriptor write operation, and we must emit a signal. Oh, and set endHandle correctly on a LE service object! Change-Id: I71922507a6ece987ad8b5c317ef618301ae240c2 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QtBluetooth - add LE device discovery timeout (OS X/iOS)Timur Pocheptsov2016-06-161-4/+0
| | | | | | | | | | | | | | - Instead of hardcoded 10 second timeout use the latest Qt API enabling arbitrary or infinite length for LE device discovery. - Since now scan can take long or unlimited time, the previous approach with detached CBCentralManager and DDA is not working anymore - we can not report devices only at the end of scan. Re-use LENotifier and signals/slots instead. - Remove DDA timer, timeout logic is completely inside osxbtledeviceinquiry object now. Change-Id: I07735581ac175d1d5e5d788aaf697dcb41429e31 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QtBluetooth - get rid of outdated Q_FUNC_INFO use patternTimur Pocheptsov2016-06-031-70/+58
| | | | | | | No Q_FUNC_INFO in qCDebug/Warning/Critical needed anymore. Change-Id: I0e47ccc7ffa971b8277b8d742e00319f4acef2f7 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QtBluetooth: remove outdate code (OS X/iOS)Timur Pocheptsov2016-06-021-37/+21
| | | | | | | | | 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>
* QtBluetooth (BTLE) - fix build on tvOSTimur Pocheptsov2016-05-231-2/+35
| | | | | | | | CoreBluetooth for tvOS does not support peripheral role. Change-Id: I82e7a61abfd907ea53faf33264951727f3cbe5a2 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Add peripheral role (iOS/OS X).Timur Pocheptsov2016-03-131-107/+247
| | | | | | | | | 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>
* Bluetooth LE: Add support for Signed Write command in the central role.Christian Kandeler2016-02-171-2/+2
| | | | | | Task-number: QTBUG-41175 Change-Id: I62d74236faf9161681306d952e409e23e0cea24d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Merge remote-tracking branch 'gerrit/dev' into neardAlex Blasche2016-01-261-15/+21
|\ | | | | | | Change-Id: If9cf6718cbd619dd7ce38db2da274fe9d0a41fb7
| * Updated license headersAntti Kokko2016-01-201-15/+21
| | | | | | | | | | | | | | | | | | | | 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>
* | Bluetooth LE: Add connection update functionality.Christian Kandeler2016-01-181-0/+6
| | | | | | | | | | | | | | Implemented for BlueZ only. Change-Id: I358a98bbc7499d5ce5437fb0d4672fde46c3b831 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Merge remote-tracking branch 'gerrit/dev' into neardAlex Blasche2016-01-051-12/+6
|\| | | | | | | | | | | | | Conflicts: src/bluetooth/qlowenergycontroller.cpp Change-Id: I28b116deb3fa87169432eb2d94b70894359a9057
| * Remove unused isConnecting member variable in QLECPrivateOSXAlex Blasche2015-12-231-13/+6
| | | | | | | | | | | | | | | | | | Most likely it was used before some changes rendered it unused. At this point the variable was initialized to false and never ever set to true. Change-Id: I5b60cf83bc362ff53f8ce276c16392aada9efc69 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
| * OSX/iOS: Invalide QTLE services when remote device disconnectsAlex Blasche2015-12-231-0/+1
| | | | | | | | | | | | | | | | So far, only a local disconnect triggered the invalidation process. Task-number: QTBUG-50125 Change-Id: I324e01c86eb0c7cc820e91a6f6d6d01fb23170ab Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* | Merge remote-tracking branch 'gerrit/dev' into neardAlex Blasche2015-12-221-105/+237
|\| | | | | | | Change-Id: I48826b6a83d8876b97095387cd329165a534eec2
| * qlowenergycontroller_osx - move delegate to the qt_LE_queueTimur Pocheptsov2015-12-101-105/+237
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'gerrit/dev' into neardAlex Blasche2015-12-031-7/+9
|\| | | | | | | Change-Id: I1fc766d26aadb7cc01d33c4c8a2260411d7bb138
| * Merge remote-tracking branch 'gerrit/5.5' into 5.6Alex Blasche2015-12-011-7/+9
| |\ | | | | | | | | | Change-Id: I4404df69bfdac335e9c1eb63e4ada3ba89b48b6c
| | * Don't register meta types during static init time5.5Alex Blasche2015-11-301-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QMetaType register my not be up and running by the time we attempt these meta type registration. Change-Id: I1a857a936a24b4b00a49574fac311c08c09b3d5a Task-number: QTBUG-49455 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | Bluetooth: Add API to set up GATT services.Christian Kandeler2015-11-201-0/+9
| | | | | | | | | | | | | | | | | | | | | This is the next step in implementing LE peripheral support. Change-Id: I5e8cb186d556e7bfb9ae8a5e60e051ff7398b77d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | Bluetooth: Introduce API for LE advertising.Christian Kandeler2015-11-171-0/+45
|/ / | | | | | | | | | | | | And provide an implementation for BlueZ. Change-Id: I302aee7c43b77016d9e1e7a0d5bcbf00096abf76 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* / [Bluetooth] Optimize loopsKonstantin Ritt2015-09-161-20/+41
|/ | | | | | | | | | | | Decrease complexity from O(N+N*logN) to just O(N) for cases like foreach (Key key, map.keys()) Value value = map.value(key); , by rewriting with use of iterators. Change-Id: I81f1334797f16b624293fcebdee885b2be3c89f1 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* add remoteName() method to QLowEnergyControllerKevron Rees2015-05-121-0/+8
| | | | | | Task-number: QTBUG-45435 Change-Id: I3ded6bf88d3980481e386073ce160d5d54520034 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Bluetooth LE - add readCharacteristic/readDescriptor (OS X/iOS)Timur Pocheptsov2015-04-201-0/+74
| | | | | | | Add read descriptor/characteristic support for iOS and OS X. Change-Id: If7547f3756dc37930052c9cefd243d6063bcab1c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Shift all OSX & iOS translations into C++ filev5.5.0-alpha1Alex Blasche2015-03-061-4/+5
| | | | | | | | | | | lupdate cannot parse .mm files. Therefore tr markup must be inside of C++ files. Some error strings where slightly modified to make use of already existing translations for other backends such as Bluez and QNX. Change-Id: I97fe6cfe2227e32fdbc61edd253080a1cd68edc9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-161-7/+7
| | | | | | | | | 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>
* Bluetooth - check OS X/iOS version in runtimeTimur Pocheptsov2015-02-061-4/+8
| | | | | | | Add runtime version checks, compile time can be not enough. Change-Id: If59131b3a9039a7fe15ccba0346fa71d58f36736 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController/CentralManager - cleanup (OS X/iOS)Timur Pocheptsov2014-12-091-76/+62
| | | | | | | | | 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>
* QLowEnergyController - bug fixes (OS X, iOS)Timur Pocheptsov2014-12-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | 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 - localAddress (OS X)Timur Pocheptsov2014-12-051-2/+7
| | | | | | | | On OS X QLowEnergyController can return the valid local address, even if it was constructed without this parameter. Change-Id: I40252a9f1f64506ae23d6dfe1e61fc786e895860 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Client characteristic configuration (OS X and iOS)Timur Pocheptsov2014-12-051-2/+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>
* QLowEnergyCharacteristic - cached values (OS X and iOS)Timur Pocheptsov2014-12-041-2/+6
| | | | | | | | Cache a characteristic's value in update/write notification only if characteristic has a 'Read' property. Change-Id: Idc705e0c4f2ee704a80bf37b4e59e1dd09ca9e4f Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyService - ClientCharacteristicConfigurationTimur Pocheptsov2014-12-031-16/+47
| | | | | | | | | 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 - service state (OS X/iOS)Timur Pocheptsov2014-12-011-4/+4
| | | | | | | | Fix a bug - call setState on a service instead of stateChanged (which is just a signal not actually chanding the service's state). Change-Id: I243f1f6c6775a5592357a443a2f180e4afcf8219 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - concurrent characteristic writesTimur Pocheptsov2014-12-011-58/+12
| | | | | | | | | | 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-14/+75
| | | | | | | 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-48/+19
| | | | | | | | | | | | | 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/+186
| | | | | | | 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-5/+97
| | | | | | | | | | 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>
* QLowEnergyService - primary/secondary (OS X and iOS)Timur Pocheptsov2014-11-251-0/+2
| | | | | | | | It looks like isPrimary property is always 'NO' on CBService objects discovered making this property ... hmm, TOTALLY USELESS? Change-Id: Ia38323c204e6cf1c3def3bbb3deb08bb8cdf90e4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QLowEnergyController - service discovery (OS X and iOS)Timur Pocheptsov2014-11-241-52/+195
| | | | | | | | | | | 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-1/+12
| | | | | | | | | | | | | | | | | | | | 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-6/+54
| | | | | | | | | | | 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-5/+174
| | | | | | | | | | | | | 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>
* QLowEnergyController - version for OS X and iOSTimur Pocheptsov2014-11-121-0/+210
QLowEnergyController/Private for OS X and iOS. This patch contains dummy empty classes required. While LE controller is not fully implemented, I have to disable (marking as insignificant) auto test on this class, otherwise changing the (empty) class to pass the test adds more problem. Change-Id: I54f764f7f6468b1acf58e80555ae454922de9f3b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>