Commit graph

63 commits

Author SHA1 Message Date
Jan Mulder
6031692a39 Use waitFor instead of timer
See e79bede0aa. We rather use wait in combination
with spinning the event loop.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04 23:46:07 +09:00
Jan Mulder
f6768cedf3 OSTC over BLE: Select the right service
The current "select the correct BLE service to talk to" is flawed.
It assumes that the first found non-standard UUID is the right one
and apparently it is for some DCs. But not for the HW devices.
The HW devices use a "standard" ie. approved by the Bluetooth
SIG, controller, that comes with a UUID that our code currently
considers standard so not to be the right one.

This (simple) commit selects the right service for HW. The UUID
is hard coded, and this is ok, because it is tied to the hardware
used by HW. Futher, it does not change anything for other BLE
devices.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04 23:46:07 +09:00
Jan Mulder
6fe0388b96 OSTC over BLE: initialize Terminal I/O client
This initalizes the Terminal I/O client as described in paragraph 3 of
http://www.telit.com/fileadmin/user_upload/products/Downloads/sr-rf/BlueMod/TIO_Implementation_Guide_r04.pdf

This is for all Heinrichs Weikamp computers, that use referenced BT/BLE hardware
module from Telit Wireless Solutions (Formerly Stollmann E+V GmbH). The 16 bit
UUID 0xFEFB (or a derived 128 bit UUID starting with 0x0000FEFB is a
clear indication that the OSTC is equipped with this BT/BLE hardware.
Furthermore, most devices equipped with this BT/BLE hardware have BT addresses
starting with 00:80:25:...

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04 23:46:07 +09:00
Dirk Hohndel
bc1a313c9f Increase the BLE timeout to 12 seconds
This seems really long, but one user appeared to get a response after
almost 10 seconds. So going with 12 for some margin of error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-03 22:22:16 -07:00
Dirk Hohndel
f98fa50c39 BLE code: address some compiler warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27 20:53:11 -07:00
Linus Torvalds
526595644f Use SSRF_CUSTOM_IO v2 to implement device data quirks for BLE GATT
Right now we have a quirk for Shearwater devices to set the random
address flag, but also to handle the differences at read/write time.

With this, I can finally download from both the Suunto EON Steel and the
Shearwater Perdix AI with the same binary.

It's not *pretty*, but it works.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 15:14:27 -07:00
Alex Blasche
e79bede0aa Use QLowEnergyController without QEventLoop
We rather use wait in combination with spinning the event loop.

Signed-off-by: Alex Blasche <alexander.blasche@qt.io>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 11:03:19 -07:00
Alex Blasche
57753321b0 Ensure all found BLE services are tracked
If a device has more than one service the order of service discovery
determined the selection of the service that we intend to interact
with. This assumption is not accurate and is even platform dependent.

Thinking ahead, it is likely that some devices may require us to keep
track and interact with multiple services at the time.

The new logic still suffers from the fact that there is no way
to select the correct service for interaction. This will require
higher level stack changes.

Signed-off-by: Alex Blasche <alexander.blasche@qt.io>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 11:03:19 -07:00
Alex Blasche
81dabe5ace Fix incorrect uuid check due to temporary char* in QString::toUtf8()
toUtf8() creates a temporary char* representation which is assigned to
uuid. As soon the object created by toUtf8() gets destroyed, the uuid
pointer points to releases memory.

The intention is to check that we don't have one of the standard
16bit Bluetooth uuids. That's the purpose of QBluetoothUuid::toUInt16().

Signed-off-by: Alex Blasche <alexander.blasche@qt.io>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 11:03:19 -07:00
Linus Torvalds
d0c3ef4cf8 Bluetooth: make LE-only devices add "LE:" as an address prefix
This seems a bit odd, but it actually has three different reasons for it:

 - It's a visual indication of BT LE mode for users

 - the rfcomm code only works with legacy BT support, and if we scan a
   device that only does LE, we want the custom serial code to instead
   automatically fall back on a "emulate serial over LE packets" model.

 - we want rfcomm to remain the default for devices that do both legacy
   BT _and_ LE, but we want people to have the ability to override the
   choice manually.  They can now do so by just editing the address
   field and adding the "LE:" prefix manually, and it automatically gets
   saved for next time.

So while a bit hacky, it's actually a very convenient model that not
only works automatically, but allows the manual override.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-26 22:20:01 -07:00
Dirk Hohndel
6f1590b098 BLE support: convert fprintf(stderr,...) to qDebug()
This way the output can be seen in the AppLog on Android.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24 22:32:47 -07:00
Dirk Hohndel
63fc06e728 BLE support: add SPDX headers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24 22:32:01 -07:00
Linus Torvalds
196adb591b Very early and likely quite broken BLE GATT code
This is some very early and hacky code to be able to access BLE-enabled
dive computers that use the GATT protocol to send packets back and forth
(which seems to be pretty much all of them: a vendor-specific GATT
service with a write characteristic and a notification characteristic
for reading).

For testing only.  But it does successfully let me download dives from
my EON Steel and my Scubapro G2.

NOTE! There are several very hacky pieces in here, including just
"knowing" that the write characteristic is the first one, and the
notification characteristic is second.  The code should actually check
the properties rather than have those kinds of hardcoded assumptions.

It also checks "vendor specific" by looking at the UUID string
representation, and knowing that the standard ones start with zero.
Crazily, there doesn't seem to be any normal way to test for this,
although I guess that maybe the uuid.minimumSize() function could be
used.

There are other nasty corners. Don't complain, send me patches.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24 21:58:01 -07:00