aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
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>
2017-06-24BLE support: convert fprintf(stderr,...) to qDebug()Gravatar Dirk Hohndel
This way the output can be seen in the AppLog on Android. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24BLE support: add SPDX headersGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24Very early and likely quite broken BLE GATT codeGravatar Linus Torvalds
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-24QML UI: DiveList: add date box to trip headerGravatar Dirk Hohndel
This way you can tell when a trip happened. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-23Translate "more than n days" for surface intervalGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-06-22Warn when not compiling against the matching libdc versionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22Merge branch 'master' of git://github.com/torvalds/subsurface-for-dirkGravatar Dirk Hohndel
2017-06-23Typo of translated stringGravatar Jan Mulder
Trivial typo. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-22Convert to new libdivecomputer custom IO modelGravatar Linus Torvalds
Instead of being "custom serial", it's a IO model that allows serial or packet modes, independently of each other (ie you can have a bluetooth device that does serial over BT rfcomm and packet-based communication over BLE GATT with the same serial operations that describe both cases). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-22Use plural form for cloud connection waitGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22Add en_US translation for pluralsGravatar Dirk Hohndel
This way in the en_US locale we no longer get shown the odd "dive(s)" and instead get correct singular and plural forms. Most of the patch is just a reindentation as it removes the if clause that used to do the special case of NOT loading a translation for the en_US case. Right now we start with a trivial en_US translation file. My guess is that this will be overwritten once we do the next round of "new strings, new translations". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22QML UI: correctly build plural translationGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22mobile: prune DC list to download fromGravatar Jan Mulder
Currently, only a small number of dive computers can be downloaded from the mobile app. Only present the supported ones to the user. So, currently restricted to classic BT. Not sure about FTDI support at this point. Version 2 of the same commit after review from Dirk. Fundamentally, support is as follows: Android: BT, BLE, and FTDI. iOS: BLE only. For all other OSses, this commit has no changes. As the BLE backend is not yet ready, no support on iOS yet. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-22Preserve VPM-B state in profile displayGravatar Robert C. Helling
This fixes a but reported by Willem in the display of VPMB ceilings for logged dives. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-06-18QML UI: use the short date formatGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-18Clean up git storage update messagesGravatar Dirk Hohndel
Translate all of them, but also remove some redundant or possibly misleading messages. These are now seen by users, not just developers trying to debug the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17QML UI: redesign the user notificationGravatar Dirk Hohndel
The old system of cloud access updates with fake percentages just wasn't helpful. Even worse, it hid a lot important information from the user. This should be more useful (but it will require that we localize the messages sent from the git progress notifications and make them more 'user ready'). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17Set default cloud timeout to ten seconds for mobile appGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-15tankinfomodel.cpp: clamp row index to [0 - MAX_TANK_INFO]Gravatar Lubomir I. Ivanov
MAX_TANK_INFO is a new macro in dive.h to define the maximum number of tank_info_t objects. TankInfoModel's data() and setData() now check for valid row indexes before accessing the tank_info[] array directly. Without this patch TankInfoMode::data() can cause a SIGSEGV. Reported-by: Pedro Neves <nevesdiver@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-15Fix buffer overrun and primary sensor id issues in Liquivision importGravatar Robert Bodily
This changeset fixes 5 issues specific to importing from Liquivision dive logs: Issue #1: Buffer overrun causes segmentation fault. At the end of a dive record, untranslatable data is skipped and the file is scanned for the start of the next dive. This scan was implemented without regard to buffer size and so the scan ran over the buffer boundary when trying to scan for the next record after importing the last record in the file. Issue #2: Incorrect identification of the primary sensor. The primary tank pressure transmitter was being identified by using the sensor ID reported in the first pressure event record encountered. When diving with multiple transmitters (buddy, student, or group transmitters), this is often not the case and results in the buddy or other group transmitter's pressure data being imported instead of the primary's. Through empirical observation of several multi-sensor logs, I identified a previously unhandled event code (0x10) as marking a sensor identification event record. Parsing this record allows the primary and other sensors to be definitively identified regardless of which one sends the first pressure event. Issue #3: Sensor values added to the sample collection regardless of sensor ID. When processing events, the code previously dropped through to create a sample for every pressure event record, regardless of which sensor ID that event is associated with. Pressure events for sensors other than the primary are now ignored and omitted from the sample collection. Issue #4: Duplicate samples when pressure event time syncs with sample time. The sample index (d) was not incremented in this specific case resulting in a duplicate sample (for the same sample time) being created when processing the next pressure event record. Issue #5: Unsigned time difference results in erroneous interpolated samples. When interpolating/extrapolating depth and temperature values for a between- samples pressure event, a signed time value is subtracted from an unsigned time value, resulting in an unsigned term. This term is used as a scaling factor and should be signed to allow for a negative value. Currently, negative values are instead treated as large unsigned values which result in erroneous scaled depth and temperature values. Signed-off-by: Robert Bodily <robert@bodily.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-16code cleanup: remove 2 unused structsGravatar Jan Mulder
Luckily these 2 structs in this ugly code are not used. Remove them. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-13Parse He when importing from DM5Gravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-06-12BT Discovery: add Shearwater Petrel and PerdixGravatar Jan Mulder
Add Shearwater Petrel and Perdix to automatic detection Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-12Don't declare static function in .h fileGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>