"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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
See also b409e9fc91 and 709c1df2af. 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 709c1df2af, 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>
Commit 709c1df2af 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>
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>
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>
This reverts commit ed43b5dced ("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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>