aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2017-07-16Add the connections that we find to the modelGravatar Dirk Hohndel
So far this only deals with BT addresses. We also need to add other connections that we detect. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-16Add ConnectionListModelGravatar Dirk Hohndel
We'll use that to do a better job of showing the connection used when talking to a dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-15Correct BT detect for OSTC SportGravatar Jan Mulder
Apparently, OSTC Sport has a BT name like OSTCs<space><serial>. Small code addition to detect this properly. As long as we do not have an improved way of detection. Notice that most of the HWs use the same BT hardware, so simple detection on offered services will not work. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-12BT support: track if Bluetooth is availableGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-11Trivial code cleanupGravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-11OSTC over BLE: read a long as neededGravatar Jan Mulder
See also b409e9fc91d87bbd5 and 709c1df2af4b87. The OSTC parser cannot handle reads of single 20 byte BLE packages in serial mode. Instead of doing a deeper down agressive read, we can read on the serial level more subtile. As the parser is requesting a specific number of bytes, we just read that number of bytes and return them. As the 20 byte BLE packets do (obviously) not align with the reading requirement of the libdc parser, a little housekeeing needs to be done in between individual reads. CAVEAT 1: In contradiction to 709c1df2af4b87, this is supposed to work for all parsers that properly specify the needed bytes to fetch. CAVEAT 2: All above tested on Linux Desktop with bluez stack. Subsurface mobile is step 2. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-11BLE read: remove aggressive readGravatar Jan Mulder
Commit 709c1df2af4b87 introduced a hard blocking read for BLE devices. This did break BLE reads from multiple DCs, and (in hindsight) was not a correct implementation. It would require, for example, dynamic read buffers as especially profile data grows with dive time, and in addition, and more importantly, also the OSTC libdc parser cannot process the entire profile of a dive at once (but likes to receive it in 1K blocks). So, basically, it introduced issues, and did not solve the OSTC read. This commit reverts this hard blocking read (and as such will break OSTC BLE reads). But it enables removal of the special cases for the EON Steel and G2. A next commit will solve OSTC BLE reads. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-11OSTC over BLE: take care of creditsGravatar Jan Mulder
Handle credits. Do not just ask for maximum credits all the time as this will stop the download. Also do not let the credits go back to 0 (while this might work, this is not tested). Getting back the 0 credits stops the download, and even when it can be restarted, it is less efficient (and not needed). Notice also that it takes some time before a grant request is honoured. During testing I saw reception of up to 25 packets between request and grant. So a lower bound for the request of 32 packets seems resonable. One aspect the Telit/Stollmann TIO puzzeled me. Sections 4.1 and 4.2 both talk about credits, but my hyphothesis is that there are two credits counters in play. One for traffic either way. This commit only deals with credits granted by Subsurface to the OSTC to send data. Credits granted by the OSTC to allow Subsurface to send new commands is NOT part of this commit, and is seemingly not needed in our scenario. As we only send new commands to the OSTC when a previous one is finished (per HW's interface spec), the OSTC does not run out of credits to receive commands. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-09Tell user if we reached a dive that was already thereGravatar Dirk Hohndel
This way it's more obvious why no dives were downloaded. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09More meaningful device info displayGravatar Dirk Hohndel
While it's nice to have the numerical model in the logfile, on the screen the user wants to see the dive computer product name. And none of those hex numbers that make the text so long that it becomes useless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09Revert "Add support for tank sensor battery for Perdix AI"Gravatar Dirk Hohndel
This reverts commit ed43b5dcedd150235cdc1ac5e5aedecb62f1c657 ("Add support for tank sensor battery for Perdix AI") since a much better solution to get to that information has been implemented in libdivecomputer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09QML UI: add dev_info data to AppLogGravatar Dirk Hohndel
This should make it easier to tell how far we get downloading data from dive computers. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09BLE support: the G2 wants packages one at a timeGravatar Dirk Hohndel
Just like the EON Steel it doesn't want us to loop until all packages have been received. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-08Automate picking supported DCs on iOS and AndroidGravatar Dirk Hohndel
We use a little script to create the code snippet. This script in return relies on comments that were added to the latest libdivecomputer source (in the Subsurface-branch). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-08If we detect a different model than expected, use itGravatar Dirk Hohndel
This is useful if the underlying code in libdivecomputer can reliably detect specific hardware models. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07Add support for tank sensor battery for Perdix AIGravatar Dirk Hohndel
This is a bit awkward with a VENDOR event - but at the time the strings are generated, we don't have the information, yet, that we need to determine these values (we need the last sample parsed, but the strings are created as part of the dive headers. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-06BLE: reduce the noise of debug outputGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-06BLE: minor code cleanupGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-06Make compile with Qt developer buildsGravatar Alex Blasche
subsurface/core/divesitehelpers.cpp: In member function 'virtual void ReverseGeoLookupThread::run()': subsurface/core/divesitehelpers.cpp:128:12: error: invalid use of incomplete type 'class QDebug' qDebug() << "no reverse geo lookup; geonames returned\n" << fullReply; ^ Signed-off-by: Alex Blasche <alexander.blasche@qt.io>
2017-07-04BLE download: EON Steel doesn't want to loop over readsGravatar Dirk Hohndel
This seems a bit brutal, but it does the trick and makes EON Steel downloads work again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-04BLE: write confirmation isn't HW onlyGravatar Dirk Hohndel
Happens on the Suunto EON Steel as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-04Address code reviewGravatar Jan Mulder
Addresses code review by Dirk. No functional changes. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04BLE: read until no more data in coming inGravatar Jan Mulder
The current BLE read reads just one 20 bype packet. That packet size is set in ble_serial_ops, so, without being able to test on anything other than a OSTC3, I assume that this holds for other BLE DCs too. So, I think is is weird that those interfaces work with the current read() of just one packet at the time. As we need a blocking read (at least for the OSTC parser), just read all data that is available on the input. And when we think we are done, give the QtEventloop control to see if there is more, and process that incoming data as well. All this basically implements a blocking read. CAVEAT 1: This might break the reading from the currently working BLE devices. CAVEAT 2: With this, I still cannot read the OSTC3 completely. For developers familiar with the HW transfer protocol: it just stops while reading the first full dive (header + profile) command 0x66, despite correctly reading about 5Kb of data before. For some reason, I do not believe that this is related to this commit. CAVEAT 3: All above tested on Linux Desktop with bluez stack, and confirmed NOT to work on Android 7.1.2, build with Qt 5.9.0, And yes, I know 5.9.1 recommended. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04OSTC over BLE: filter and track OSTC credit trafficGravatar Jan Mulder
1) As the OSTC sends data to the BLE central role (the SSRF client) over 2 characteristics, we have to filter the administrative credit data from the actual dive data that it received. The characteristcStateChanged function is adapted for this. 2) We have to be sure that the Terminal Client I/O is fully defined during opening the connecton to the OSTC. From 6d505b24f0c15 we can see that the last step in setting up the terminal interface is the grant of credits. This is done by writing to the proper (the only one, with id = 0x2902) descriptor of the credits RX characteristic. The here added slot is triggered on the completion of write of credits marking the final stage of the setup. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04Use waitFor instead of timerGravatar Jan Mulder
See e79bede0aa5b3bd. We rather use wait in combination with spinning the event loop. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-04OSTC over BLE: Select the right serviceGravatar Jan Mulder
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-04OSTC over BLE: initialize Terminal I/O clientGravatar Jan Mulder
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-03Increase the BLE timeout to 12 secondsGravatar Dirk Hohndel
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-03Rewrite the matching code for BT devicesGravatar Dirk Hohndel
This should be much more robust in getting us the correct Bluetooth address and the correct vendor / product for our selection. When we pick a paired device, we extract the address right from its name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-03Don't add all discovered BT devicesGravatar Dirk Hohndel
This really doesn't help us as we can't associate a vendor/product with devices we don't recognize, so we can't download from them, anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-04Don't try to dereference empty product/vendor listGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-07-04BT discovery Android: Allow BT/LE devices connect both waysGravatar Jan Mulder
For DCs that support both BT and LE, allow the user to connect to both interface layers. Maybe not usefull in the end (as BT is faster than LE), but as long as BT on Android is WIP is it very useful to be able to connect to the interface layer we like. Just add it to the Paired Devices list twice. The normal way, and the LE: prepend way. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-03Don't warn about missing en-US translation for QtGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-02QML UI: add more dive computersGravatar Dirk Hohndel
This really needs to be done differently - we need a structured way to associate a transport mechanism with each of the dive computers we support. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-02BT discovery: detect Scubapro G2Gravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-30Android: mark BLE only paired devicesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-30QML UI: save BT address as stringGravatar Dirk Hohndel
And do the same LE: prefix marking as in the desktop version. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-30BLE handling: create helper function to add the LE: prefixGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27Fix one call site that hadn't been updatedGravatar Dirk Hohndel
When updating to the new dc_custom_io_t, this one spot had been missed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27WhitespaceGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27BLE code: address some compiler warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27Update Subsurface-branch of libdivecomputer checkGravatar Dirk Hohndel
We now require the Subsurface-branch, and at least version 2 of the Subsurface API of libdivecomputer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27Use SSRF_CUSTOM_IO v2 to implement device data quirks for BLE GATTGravatar Linus Torvalds
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-27Switch over to SSRF_CUSTOM_IO v2Gravatar Linus Torvalds
I hate changing the IO interfaces this often, but when I converted the custom serial interface to the more generic custom IO interface, I intentionally left the legacy serial operations alone, because I didn't want to change something I didn't care about. But it turns out that leaving them with the old calling convention caused extra problems when converting the bluetooth serial code to have the BLE GATT packet fall-back, which requires mixing two kinds of operations. Also, the packet_open() routine was passed a copy of the 'dc_context_t', which makes it possible to update the 'dc_custom_io_t' field on the fly at open time. That makes a lot of chaining operations much simpler, since now you can chain the 'custom_io_t' at open time and then libdivecomputer will automatically call the new routines instead of the old ones. That dc_context_t availability gets rid of all the if (device && device->ops) return device->ops->serial_xyz(..); hackery inside the rfcomm routines - now we can just at open time do a simple dc_context_set_custom_io(context, &ble_serial_ops); to switch things over to the BLE version of the serial code instead. Finally, SSRF_CUSTOM_IO v2 added an opaque "dc_user_device_t" pointer argument to the custom_io descriptor, which gets filled in as the custom_io is registered with the download context. Note that unlike most opaque pointers, this one is opaque to *libdivecomputer*, and the type is supposed to be supplied by the user. We define the "dc_user_device_t" as our old "struct device_data_t", making it "struct user_device_t" instead. That means that the IO routines now get passed the device info showing what device they are supposed to download for. That, in turn, means that now our BLE GATT open code can take the device type it opens for into account if it wants to. And it will want to, since the rules for Shearwater are different from the rules for Suunto, for example. NOTE! Because of the interface change with libdivecomputer, this will need a flag-day again where libdivecomputer and subsurface are updated together. It may not be the last time, either. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27Use QLowEnergyController without QEventLoopGravatar Alex Blasche
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-27Ensure all found BLE services are trackedGravatar Alex Blasche
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-27Fix incorrect uuid check due to temporary char* in QString::toUtf8()Gravatar Alex Blasche
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-26BT serial: recognize LE-only devices, and fall back to emulated serialGravatar Linus Torvalds
This is somewhat hacky, but it allows at least the Shearwater libdivecomputer backend to continue to treat even the BLE GATT model as just a serial protocol. What it does is create a special "emulate serial behavior over the packetized BLE protocol" helper layer, that qtserialbluetooth falls back on when rfcomm is not available. NOTE! This still requires some BLE packet code changes to work with the odd way that Shearwater sets up their BLE GATT communication. So note that no further patches are necessary to *libdivecomputer*, but some updates are needed for the subsurface qt-ble.cpp code. I have those updates in my tree, and this code is all tested on my Perdix AI, but those patches are currently too ugly to commit as-is. I've cleaned up this "fake serial" code sufficiently, that cleanup comes next. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-26Bluetooth: make LE-only devices add "LE:" as an address prefixGravatar Linus Torvalds
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-24Add the EON Steel as support DC on AndroidGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>