aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2017-07-25Mobile: honour location service time thresholdGravatar Jan Mulder
Independ of the settings, the threshold to reset the GPS data was hard coded to 5 minutes. Now, honour the entered (and updated during a session) time to refresh the GPS data in the location service. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-25Try to sanely download multiple concurrent cylinder pressuresGravatar Linus Torvalds
This tries to sanely handle the case of a dive computer reporting multiple cylinder pressures concurrently. NOTE! There are various "interesting" situations that this whole issue brings up: - some dive computers may report more cylinder pressures than we have slots for. Currently we will drop such pressures on the floor if they come for the same sample, but if they end up being spread across multiple samples we will end up re-using the slots with different sensor indexes. That kind of slot re-use may or may not end up confusing other subsurface logic - for example, make things believe there was a cylidner change event. - some dive computers might send only one sample at a time, but switch *which* sample they send on a gas switch event. If they also report the correct sensor number, we'll now start reporting that pressure in the second slot. This should all be fine, and is the RightThing(tm) to do, but is different from what we used to do when we only ever used a single slot. - When people actually use multiple sensors, our old save format will start to need fixing. Right now our save format comes from the CCR model where the second sensor was always the Oxygen sensor. We save that pressure fine (except we save it as "o2pressure" - just an odd historical naming artifact), but we do *not* save the actual sensor index, because in our traditional format that was always implicit in the data ("it's the oxygen cylinder"). so while this code hopefully makes our libdivecomputer download do the right thing, there *will* be further fallout from having multiple cylinder pressure sensors. We're not done yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-24CCR is now detected from the log dataGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Map Divinglog's visibility to our starsGravatar Miika Turkia
good (1) = 5 medium (2) = 3 bad (3) = 1 There seems also to be 0 used in the log, even though it is not mentioned in the valid selections. This is not giving any stars for this option... Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Detect CCR/PSCR from Divinglog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Fix CCR detection on Divinglog importGravatar Miika Turkia
Note that I have not been able to do a positive test for this due to lack of CCR sample data. But at least OC dives are now categorized correctly. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Add visibility support to Divinglog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-22QML UI: remember the last dive computerGravatar Dirk Hohndel
We already have the infrastructure to do so, all we needed to do was hook it all up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-22parse-xml: use the right dc for filling in extra dataGravatar Linus Torvalds
"cur_dc" may be NULL when the XML source isn't a subsurface XML file, and xml parsing is supposed to use "get_dc()" to pick a dive computer when the nesting of the XML may not be proper. Now, XML sources that don't have the proper dive computer nesting markers generally also do not end up having the extra-data string information, but one example of this is the simple XML that the libdivecomputer 'dctool' program generates. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-22Gas usage statistics: don't require gas switch eventsGravatar Linus Torvalds
Our "get_has_used()" helper only filled in gas usage for cylinders that had a gas change event associated with them. That works really badly for things like CCR, but also simply for cases where the dive computer wasn't necessarily explicitly notified about usage, like sidemount diving etc. Just remove the logic. If some use ends up particularly wanting to ignore some cylinder, they can always do it in the caller instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21Fix up o2 pressure sensor handling at load timeGravatar Linus Torvalds
Because of how we traditionally did things, the "o2pressure" parsing depends on implicitly setting the sensor index to the last cylinder that was marked as being used for oxygen. We also always defaulted the primary sensor (which is used for the diluent tank for CCR) to cylinder 0, but that doesn't work when the oxygen tank is cylinder 0. This gets that right at file loading time, and unifies the xml and git sample parsing to make them match. The new defaults are: - unless anything else is explicitly specified, the primary sensor is associated with the first tank, and the secondary sensor is associated with the second tank - if we're a CCR dive, and have an explicit oxygen tank, we associate the secondary sensor with that oxygen cylinder. The primary sensor will be switched over to the second cylinder if the oxygen cylinder is the first one. This may sound backwards, but matches our traditional behavior where the O2 pressure was the secondary pressure. This is definitely not pretty, but it gets our historical files working right, and is at least reasonably sensible. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21git save format: don't save redundant sample informationGravatar Linus Torvalds
When we load sample data from a git save-file, we always default to using the state from the previous sample (except for the special case of cylinder pressure where an empty value does not mean "same", but "interpolate", see core/load-git.c: new_sample()). But the corollary to that is that it's always redundant to save sample data that hasn't changed since the previous sample. For some reason, the rbt, bearing and heartrate sample data didn't follow that rule, and instead saved with lots of extra reduncancy. (The alternative would be to clear those samples at load time, and make them act like the pressure data, but it would appear that all these three values may as well just have the normal "if no change, don't save them" semantics). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21Start cleaning up sensor indexing for multiple sensorsGravatar Linus Torvalds
This is a very timid start at making us actually use multiple sensors without the magical special case for just CCR oxygen tracking. It mainly does: - turn the "sample->sensor" index into an array of two indexes, to match the pressures themselves. - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index}, since a CCR dive should now simply set the sample->sensor[] indices correctly instead. - in a couple of places, start actually looping over the sensors rather than special-case the O2 case (although often the small "loops" are just unrolled, since it's just two cases. but in many cases we still end up only covering the zero sensor case, because the CCR O2 sensor code coverage was fairly limited. It's entirely possible (even likely) that this migth break some existing case: it tries to be a fairly direct ("stupid") translation of the old code, but unlike the preparatory patch this does actually does change some semantics. For example, right now the git loader code assumes that if the git save data contains a o2pressure entry, it just hardcodes the O2 sensor index to 1. In fact, one issue is going to simply be that our file formats do not have that multiple sensor format, but instead had very clearly encoded things as being the CCR O2 pressure sensor. But this is hopefully close to usable, and I will need feedback (and maybe test cases) from people who have existing CCR dives with pressure data. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-20Unify sample pressure and o2pressure as pressure[2] arrayGravatar Linus Torvalds
We currently carry two pressures around for all the samples and plot info, but the second pressure is reserved for CCR dives as the O2 cylinder pressure. That's kind of annoying when we *could* use it for regular sidemount dives as the secondary pressure. So start prepping for that instead: don't make it "pressure" and "o2pressure", make it just be an array of two pressure values. NOTE! This is purely mindless prepwork. It literally just does a search-and-replace, keeping the exact same semantics, so "pressure[1]" is still just O2 pressure. But at some future date, we can now start using it for a second sensor value for sidemount instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19Correct list of Shearwater BLE dive computersGravatar Dirk Hohndel
Some Petrel 2 computers are dual stack. We need to list the Petrel here as well since the Petrel 2 actually identifies itself via BT/BLE as Petrel and we can't tell them appart until after we started a download. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19BLE on iOS: use uuid instead of BT addressGravatar Dirk Hohndel
iOS doesn't give us an address of BT devices. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19Move variable into the code block it is used inGravatar Dirk Hohndel
Avoids an "unused variable" warning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19BLE discovery: give the agent some timeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19iOS BLE support: no localBtDevice, go straight to discoveryGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19iOS build: need to more includesGravatar Dirk Hohndel
It's kinda odd this builds fine on other OSs, but whatever. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19BLE dive computers: add PerdixGravatar Dirk Hohndel
This is both correct (many Perdix support BLE) and necessary as the Perdix AI identifies itself (sadly) as Perdix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-19BLE serial read/write bufferGravatar Jan Mulder
The adapted define was confusingly wrong. Apparently, the BUFSIZ define was coming from some include file, and was dependent on platform (Linux 8K, Andorid 1K). Simple rewrite to a new define and a proper value for both Linux and Android. If 4K is big enhough, is a little uncertain, as its depends on the read behavior of all libdivecomputer parsers using this serial BLE interface. The buffer size needed (on read, as that is the most prominent direction when interfacing with DCs) is (most likely) 2x the maximum block the libdc parsers request at once. I did not study all parsers, but the Shearwater parser request 20 bytes at once (we know that from the 1 packet at the time read, we had before). The OSTC parser request 1K blocks for data that is longer than 1K (like profiles, header tables). The 1K we had on Android was working for Shearwater, Eon Steel, but not for OSTC,as its reads 1K at the time at max, and overflowing the buffer. So 32k or 64k seems way to big (as in, much bigger than any libdc read). Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-18QML UI: correctly match BT names with productsGravatar Dirk Hohndel
And remove the remaining references to the "Paired Bluetooth Devices". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-18QML UI: remove the Paired Bluetooth Devices virtual vendorGravatar Dirk Hohndel
We now actually handle connections in a sane manner and don't need that workaround anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-18Add detection of the Shearwater Predator via BTGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-17Resolve type confusionGravatar Dirk Hohndel
No idea why this now shows up as an error in the iOS build. We need to refer to the typedef, not the underlying struct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>