summaryrefslogtreecommitdiffstats
path: root/src/android/bluetooth
Commit message (Collapse)AuthorAgeFilesLines
* LE/Android: fix status code descriptions5.8Konstantin Ritt2017-04-101-2/+2
| | | | | Change-Id: Iee2f8e02a926129dfdd1c82d0fa84dfbb45303d3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* [REG] LE/Android: report ServiceDiscovered for an empty services as wellKonstantin Ritt2017-01-161-0/+6
| | | | | | | | a regression has been introduced by the service discoverer refactoring, causing an empty service to stuck in DiscoveringServices state for ever Change-Id: I1d339279e77f5409231d5fbd3677f9e2eb98a0a8 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Improve likelyhood that BluetoothGatt.connectGatt succeedsAlex Blasche2017-01-131-2/+29
| | | | | | | | | | | | | | | | | | | | | | The dreaded GATT_ERROR 133 (0x85) is a long standing issue in Android. There have been continued efforts to reduce it up until Android N: https://code.google.com/p/android/issues/detail?id=192561 Tests have shown that the new BluetoothGatt.connectGatt() overload is much more reliable. Android v23+ gets some relief and Android v21+ gets unofficial/hidden relief. Reports indicate that error 133 is timeing related. While the new connectGatt() call seems to resolve this problem it is throwing the timeing related error 22 more proactively. Very quick connect()/disconnect()/connect() calls can cause the error. The patch adds a more specific error code handling for error 22 to provide some hints on what the user can do to prevent it. Task-number: QTBUG-56078 Change-Id: Ib14d503701cee7ea766247b712106302cba896f3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add characteristic even if the read failsChristian Wassmuth2017-01-121-1/+6
| | | | | | | | | | | | | If during discovery the read of a characteristic fails, then this characteristic was not added to the service. This happens in a special case and not always, when we try to read from a notify only characteristic. Now the characteristic will be added even if the read fails. Task-number: QTBUG-58056 Change-Id: Ib802eeb66aeae92da690c296faf57331123353e6 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Prevents a nil exception, if a descriptor read fails during discoveryChristian Wassmuth2017-01-121-1/+2
| | | | | | | | | During discovery, if a descriptor read fails the current implementation tries to read from a nil bytearray. Now the bytearray is checked before access. Change-Id: Ic04809fa81c25c7abdd8a82a1ccefe43de7f5605 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android/LE: handle GATT status 8 (link loss)Konstantin Ritt2017-01-021-0/+2
| | | | | | | | May occur relatively too often to remain unhandled Change-Id: I89b1255605a29d959635e8d1965e9596b591b305 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add timeout handling for blocking GATT requestsAlex Blasche2016-12-071-14/+171
| | | | | | | | | | | | | | | Some GATT characteristics or descriptor do not respond when a request is being submitted. This can cause a staling of the service discovery process. This commit introduces a timeout handler which fires in such cases and ensures that service detail discovery continues with the next handle. Task-number: QTBUG-52692 Change-Id: I466e13c337f28ac944190ad3bd522ca018373b30 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge 5.8 into 5.8.0Oswald Buddenhagen2016-11-291-2/+2
|\ | | | | | | Change-Id: I1352bca5d8b8afee5e7c06fdb1172e5f3f9678b6
| * LE/Android: Pass list of advertised services found in scan recordAlex Blasche2016-11-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the advertising packet (scan record) received from BLE devices during scanning on Android devices is ignored. Consequently, the serviceUuids() method of the QBluetoothDeviceInfo class returns an empty list for BLE devices. However, this list provides important information needed by clients to identify whether a given device is of interest. This changeset implements parsing of the scan record received from the Android Bluetooth layer. The Java byte array is passed over JNI to the C++ adapter classes, where it's parsed to find any service UUIDs being advertised by the device. Parsing the scan record ourselves is required for compatibility (Qt uses "old-style" LE scan API from Android api level 18.) All found UUIDs are added to a list which is subsequently passed to the user of the QBluetoothDeviceDiscoveryAgent class via the deviceDiscovered(QBluetoothDeviceInfo&) signal. Note: not all Android devices pass the full advertisement data. The service UUID list may be empty in those cases. [ChangeLog][QtBluetooth][Android] Parse list of advertised services found in LE scan record and pass them to API client via QBluetoothDeviceInfo::serviceUuids() Task-number: QTBUG-56625 Change-Id: I253f1b841c7b15b3bbabc9e478de87c81979815e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Remove the service discovery state machine for goodAlex Blasche2016-11-291-213/+158
| | | | | | | | | | | | | | | | | | | | | | | | Now service discovery runs via the read/write queue which was already in use for normal (read|write)(characteristic|descriptor) functionality. This reduces the to be locked code section as the queue is the only locked data structure. Task-number: QTBUG-52692 Change-Id: Ide8d697b88f0ed40f83dab608b8457f45db42271 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Java uses references in container - no need to set the items in placeAlex Blasche2016-11-291-8/+2
| | | | | | | | | | | | Task-number: QTBUG-52692 Change-Id: Id9fecd98a9031f2bcb561143b66b74ccea751db2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Add more support for new queue based service discovery systemAlex Blasche2016-11-291-0/+76
| | | | | | | | | | | | | | | | The added functions are not yet hooked into the running code. Task-number: QTBUG-52692 Change-Id: I75faade55d68719d1da91348ed17c462942659ea Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Remove runningHandle variable to simplify Android backendAlex Blasche2016-11-291-81/+68
|/ | | | | | | | | | | | | | | The runningHandle variable keeps track of the same information as the GattEntry tables. We don't need two systems. This brings initial service discovery closer to the normal read/write queue system. Ultimately the goal is to merge the initial service discovery state machine and the read/write queue system into one. This reduces blocking issues and simplifies the implementation. Task-number: QTBUG-52692 Change-Id: Idd14212cb02e6c3737b5296adf1525ff7f7832a1 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Make QtBluetooth Low Energy work when Qt runs as Android serviceAlex Blasche2016-08-031-5/+5
| | | | | Change-Id: Ic0814c3f5a65ce9ac9236c41397400fc42abb572 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Make Classic QtBluetooth work as an Android serviceAlex Blasche2016-08-031-10/+22
| | | | | Change-Id: Ibde0242b058f728fd7e060b37f427c208325db13 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Bluetooth LE: Add support for Signed Write command in the central role.Christian Kandeler2016-02-171-1/+3
| | | | | | Task-number: QTBUG-41175 Change-Id: I62d74236faf9161681306d952e409e23e0cea24d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Updated license headersAntti Kokko2016-01-204-57/+81
| | | | | | | | | | 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>
* Bugfix: Bluetooth Le for Android need to close BluetoothGattPeter Rustler2015-05-111-0/+2
| | | | | | | | | | | | | | | Android can only handle a defined count of simultaneously connections to bluetooth le devices. Every Android device have a different defined amount of possible simultaneously connections. If we do not close the connection and reconnect to the device or another device, the count of used connections get up. If we exceed the maximum connection count we can not connect to bluetooth le devices anymore. The only way to recover is to restart the application to reset the open connection count. This patch closes the connection after it has been disconnected. Change-Id: Id96a69ef07eb973216495a0ba8e46fd639338165 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Avoid code duplication and don't break readWriteQueueAlex Blasche2015-04-151-82/+35
| | | | | | | | | | | | | | handleFor(Characteristic|Descriptor)() find a handle for a given char and desc. We should reuse it inside the read notifier for chars and descs. In addition, under certain circumstances the read/write queue operation was finished although the queue was not empty yet. This happened when the last read operation failed with a certain type of error. Now we always finish with a call to performNextIO(). Change-Id: Ifdb66c0b03d25ae19db7c49bcbe70eeec2665b6e Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Android: Fix read/write error reports when failure during initial callAlex Blasche2015-04-151-0/+32
| | | | | | | | | | | | | The BluetoothGatt.[read|write][Characteristic|Descriptor]() functions may immediately return under certain circumstances such as writing a read-only characteristic. So far, this "synchronous" form of error reporting was not handled. Any read error during the initial service dioscovery and its related cache population continues to surpress any read errors. Change-Id: I4987f67f4a0d2afe58cd144a577a19e0f0d43b33 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Android: Implement error reporting for char & desc readingAlex Blasche2015-04-151-17/+47
| | | | | | Change-Id: I5652075b4fde4d4927e86f5394baf176f263104f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Implement QLEService:readCharacateristic & readDescriptorAlex Blasche2015-04-151-70/+192
| | | | | | | | | | | | | In general we extend the concept of the write queue. Not only do we queue up write requests but also read requests. The handling of read errors is still missing. Right now the QLEService::error() signal is not emitted when a readCharacteristic() and readDescriptor() call fails. Change-Id: I4b4f086c351c4a29d6e48e8ee9079e9f33f36539 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-164-28/+28
| | | | | | | | | 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>
* Cleanup Bluetooth Java codeAlex Blasche2014-12-054-13/+21
| | | | | | | | These points were raised by Android-studio's Code analyzer Change-Id: I5481b7ca74ec902b289a71096879e32301ee6494 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Don't update cached char value when property is not readableAlex Blasche2014-12-041-1/+1
| | | | | | | | | In addition we update the documentation to reflect the slightly changed API behavior. Change-Id: Ieddee750aa35a32d3c01213dfbf678ee2a1d88d7 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: enable writing of characteristics without response modeAlex Blasche2014-12-041-1/+18
| | | | | | Change-Id: I9c26aaa11857db8dc33a99d42347a9b7f6281ad7 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Fix automatic notification sending when device demands itAlex Blasche2014-12-031-0/+18
| | | | | | | | | | | | | Some BTLE devices enable notifications be default. However since Android's BTLE API requires a call to BluetoothGatt.setCharacteristicNotification(..) to forward them, we have to peek at the ClientCharacteristicConfigurations during the service detail discovery and tell Android to forward the notification when required. Change-Id: Ief419404694d70a1373218c1b8275ef868a49ddb Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Add characteristic indication supportAlex Blasche2014-12-011-4/+15
| | | | | | | | | | | | | | | | | At this point in time characteristic indication is very much under- documented. We have to make some guesses along the way notifications work. Also, it turns out the code already supported indications but was not very future proof. If the ClientCharacteristicConfiguration is expanded by future Bluetooth specifications the notifications could have been enabled despite the two relevant bits not being set. All that was required was to write {0xFC FF} and the notifications would have been enabled. This was due to assumption that only the byte array {0x00 0xFF} being the disabling data set. Change-Id: I6c54d557f51977418f91baf658b62e1121785029 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Implements QLEService::includedServices() and type()Alex Blasche2014-12-011-0/+31
| | | | | | | | | | Unfortunately it is not possible to say whether a service is primary or secondary on Android. The platform doesn't expose this information. Change-Id: I9b0aad191308120d2d1992a5e7736b985a375e30 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: characteristic changed notification supportAlex Blasche2014-11-241-4/+35
| | | | | | Change-Id: I4c50df7d758390989c2e2127f7646e5d2dc34712 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Ensure that Android can deal with concurrent write requests.Alex Blasche2014-11-171-13/+101
| | | | | | Change-Id: Ib4f8381a1975e17b5b142f49e0f3f32398a46bfb Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Apply fixes pointed out by Java code analyzerAlex Blasche2014-11-141-28/+27
| | | | | | | | This covers code optimizations and one minor corner case bug. Change-Id: I9c4df9462e8610ea37a6e43e20840e537c295684 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Support for QLEService::writeDescriptor() on AndroidAlex Blasche2014-11-141-3/+50
| | | | | | Change-Id: I1c7f0491506c6f0512d097a419660c5f5e7fb144 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Support for QLEService::writeCharacteristic() on AndroidAlex Blasche2014-11-121-1/+119
| | | | | | | | Currently only the WriteWithResponse mode works and has been tested. Change-Id: I7947b67f737f5878a01704c09d3a9a532a41b820 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Improve reliability of QLEController connect()/disconnect()/connect()Alex Blasche2014-11-121-6/+49
| | | | | | | | | | | | | | | | | | | | | | | | Quick disconnecting and reconnecting caused some bugs and revealed some unreliabe API behavior on Android. The internal data structures were never cleaned up when disconnecting from the remote device. If multiple QLEService objects of the same QLEController instance requested a service discovery, every request but the first failed. This was fixed by queueing up the service discovery requests. Last but not least, reusing the same BluetoothGatt instance for the reconnect is very error prone. It may well be caused by Android API bugs. The reconnect would sometimes fail or toggle the connect/disconnect flag a couple of times which is not a problem for the Qt API itself but the stability of the related unit test (see tst_QLowEnergyController::tst_concurrentDiscovery()). Therefore we won't reuse the same BluetoothGatt instance but rather request a new one. Change-Id: I314f2a30960284b9bcd4926f4944c415a6d75788 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Don't print the Java stacktrace when reaching last entry of last serviceAlex Blasche2014-11-111-1/+1
| | | | | | | | We jump out and that's it. We expect the exception in those cases. Change-Id: I0fa1b42a0eb5893dec6f68a5353dfb5da3caa137 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* The service->characteristic->descriptor tree becomes available in QtAlex Blasche2014-11-111-22/+160
| | | | | | | | | | | | | | | | At the same time this fixes bugs the following bugs: 1.) Non-readable characteristics were not visible 2.) Crashes when descriptor/characteristic values were empty 3.) QLEService::discoverServiceDetails always finished with an UnknownError Missing/incorrect are still service details such as included services and the service type (which currently always defaults to primary service). Change-Id: Id73013a3784cd3c3f632102f13f5459ab37e95a6 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Propagate Charactereristic data to Qt layerAlex Blasche2014-11-101-0/+11
| | | | | | | | | Although this makes the lowenergyscanner example functionally complete, descriptor data and service meta data are still not accessable via the Qt API. Change-Id: Ifb84010b4fea054357c07424ac30116d1e4f9de0 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Majority of service detail discovery code on AndroidAlex Blasche2014-11-101-2/+252
| | | | | | | | | | Primarily the change adds the required data structures and interfaces on the Java side. What is missing is the reporting of the discovery details back to Qt. Change-Id: I37f2e17bb0f87b4c526f1b43a933b9b09b22be72 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Discover BTLE services on remote device on AndroidAlex Blasche2014-11-041-2/+33
| | | | | | Change-Id: Ia39e2ad21b0e84cb16a355337370ba82a11b75d0 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Add ability to (dis)connect to BTLE devices on AndroidAlex Blasche2014-11-041-1/+72
| | | | | | | | and keep tracking the connection state Change-Id: If4d05fa18c78802ae06096884fba78eed123e77f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Add BluetoothLE device scanAlex Blasche2014-10-282-2/+86
| | | | | | Change-Id: Ibbb1e9f141d494327082aebaf9e34ffe44039115 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-243-54/+30
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I7a8b8b787fcae9a178794364efdefe1021d10b1b Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Improve QBluetoothLocalDevice::connectedDevices()Alex Blasche2014-03-241-0/+52
| | | | | | | | | | | | | | | There is no API to get the list of connected Bluetooth devices on Android. However there are service API's which return a list of their current clients. In this particular case we find the GATT related service connections. We use that info to complement the internal list of connected devices. Note that although this is using Bluetooth Low Energy related API's the Qt API does not support this feature at this point in time. Task-number: QTBUG-36764 Change-Id: Ia8266f3a9d24fd16afdd636ca2d3d0a0c6b2b499 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Fix crashes due to concurrency issuesAlex Blasche2014-03-111-1/+14
| | | | | | | | | | | | | | | BroadcastReceiver.onReceive() is executed in the main thread whereas the Qt classes are in a different thread. This created issues whereby Java's qtObject pointer was reset by the Qt classes/thread but onReceive still trying to access the same object later on. In most cases the Qt classes using BroadcastReceiver were half way through their object tear down. This patch fixes the problem by guarding qtObject against concurrent thread access and ensures that the qtObject pointer is reset before the object tear down starts. Change-Id: Iab97b0af8e10686d97419ac8504f2fe69e9536f3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix crash when interrupting QBluetoothSocket's input stream threadAlex Blasche2014-02-272-1/+105
| | | | | | | | | | | | The previous QThread did not always properly resume when InputStream.read() was interrupted by BluetoothSocket.close(). This patch converts the QThread to a Java thread which works as the Android API docs suggested. Task-number: QTBUG-37061 Change-Id: Id6ac9b57a28f3b532cbe49ff1dfdc9d1e6432aaa Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Fix crash in QBluetoothServer::close()Alex Blasche2014-02-272-1/+156
| | | | | | | | | | | | | | Java's BluetoothSocketServer.accept() is meant to be interrupted via BluetoothSocketServer.close(). Unfortunately if the surrounding thread is a QThread the returning accept call crashes the thread. This does not happen if it is a Java Thread. This commit changes the server's private backend to a Java thread. Task-number: QTBUG-36754 Change-Id: I5aacc5444bbcd1275a11743b6aa04d2b11a5b22b Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Port QtBluetooth to AndroidAlex Blasche2014-02-136-0/+142
This is a feature merge to dev targeting Qt 5.3. Known issues: -QTBUG-36754: QBluetoothServer::close() crashes -QTBUG-36763: QBluetothTransferManager port to Android not possible -QTBUG-36764: Improve QBluetoothLocalDevice::connectedDevices() -QTBUG-36810: Remove direct use of Android action strings The above issues and some other minor TODO's will be addressed until final release time. Task-number: QTBUG-33792 [ChangeLog][QtBluetooth][Android] QtBluetooth has been ported to Android. Change-Id: I31ba83e3b7d6aa68e7258b7e43235de7d1a6e68a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>