1793 Commits

Author SHA1 Message Date
Linus Torvalds
3c25c78bae Mares: increase timeout to 3 seconds
The Mares Bluetooth dongle is some seriously messed up stuff, and takes
forever to answer anything.  I'm not sure what we do wrong, because the
Mares mobile App seems to be able to work with it without the excessive
delays, but it is really incredibly slow when we talk to it.

I suspect the dongle has has some "wait until buffer is half full"
timeout, and it then triggers for every command and short reply in both
directions, and there's likely some way to flush it, but I didn't see
anything back when I had one for testing.

Anyway, as a result, one second is just about the latency that the
dongle itself adds regardless of anything else, so when the dive
computer itself needs a timeout to think about things, the overall
timeout needs to be noticeably more than one second.

Three seconds seems to be a somewhat reasonable compromise, and we do
have documentation for it being the right value:

 "Then shalt thou count to three, no more, no less. Three shall be the
  number thou shalt count, and the number of the counting shall be
  three. Four shalt thou not count, neither count thou two, excepting
  that thou then proceed to three. Five is right out."

because we do have strong reasons to believe that the Mares Bluetooth
dongle is a beast from hell.  Everybody who has ecver met it has
certainly gone "Arrrghhh" at some point.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-28 11:35:58 -08:00
Linus Torvalds
778adb37cc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream Jef.

This is mainly just the (already merged as a separate patch) support for
th eOceanic Pro Plus 4, Jef committed the identical patch but without
marking it as BLE-capable (which is kind of pointless, since it doesn't
seem to work over anything _but_ BLE).

And a couple of trivial fixlets.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the Aeris Manta memory layout
  Add support for the Oceanic Pro Plus 4
  Strip the source directory from file names
2019-12-28 11:32:25 -08:00
Jef Driesen
02ae8d3fdb Fix the Aeris Manta memory layout
For the Aeris Manta, the end of the profile ringbuffer appears to depend
on the firmware version. For older firmware versions (1x), the end of
the ringbuffer is at address 0xFFF0, while for the newer versions (2x),
it's 0xFE00.

The code checks for firmware version 2B, because that's the lowest known
version in the 2x range.

Reported-by: Nick Shore <support@mac-dive.com>
2019-12-23 21:57:05 +01:00
Jef Driesen
9f3e0a7026 Add support for the Oceanic Pro Plus 4 2019-12-23 21:56:36 +01:00
Jef Driesen
ad297c1cc9 Strip the source directory from file names
Use the GCC 8 -fmacro-prefix-map option to strip the source directory
and change the __FILE__ macro into a relative path.
2019-12-21 20:57:06 +01:00
Jef Driesen
8711371728 Add initial support for the Oceanic Pro Plus 4
This is _partial_ support for the Oceanic Pro Plus 4 from Jef, based on
a partial dump by John Clark. Quoting Jef in the email thread:

 "I'm not sure why downloading the memory dump fails. All 4 attempts
  fail around the same memory address (0x3140), but not exactly the
  same. Strange, but the good news that there is already enough
  information to figure some things out.

  Linus and Dirk: Attached is a patch with the things I figured out so
  far. Can you make a build for John to try?

  Most of the info looks reasonable, but there are probably still a few
  things missing or wrong. I don't have any ground truth data to compare
  against for things like the temperature sign"

This is that patch for testing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-21 07:31:43 -08:00
Linus Torvalds
5290984316 Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef.

Misc small updates all over, the biggest thing (code wise) is probably
the Ratio firmware update support.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Fix the Oceanic Geo 4.0 memory layout
  Ignore all empty logbook entries
  Add a workaround for the hwOS ppO2 firmware bug
  Use macros to encode the firmware version
  Use symbolic constants for the sample types
  Remove the obsolete hwos parameter
  Limit the tank pressure workaround to hwOS devices
  Fix the OSTC tank pressure decoding
  Fix the Scubapro G2 HUD udev rule
  Add the Mares Genius to the bluetooth filter
  Add firmware upgrade support for the Ratio computers
2019-12-21 07:27:54 -08:00
Nick Shore
03c8e350dd Fix the Oceanic Geo 4.0 memory layout 2019-12-20 11:04:52 +01:00
Jef Driesen
ae733fd8a8 Ignore all empty logbook entries
The logbook ringbuffer is always updated sequentially. Therefore, emtpy
entries can only be present after the oldest dive. However it appears
that under some special conditions (for example an empty battery during
the dive), the logbook entry is not always stored correctly, which can
result in an empty entry after all.

I suspect that at the start of each dive, the OSTC erases the next
available entry in the logbook ringbuffer and updates the internal write
pointer. Once the dive is finished, the actual content of the erased
logbook is written. Thus, when the OSTC runs out of battery power during
the dive, that last step never happens, and the erased entry remains in
place.

As a workaround, ignore all empty logbook entries instead of assuming we
reached the last dive.
2019-11-29 10:29:43 +01:00
Jef Driesen
b9a3606f37 Add a workaround for the hwOS ppO2 firmware bug
Due to a bug in the hwOS Tech firmware v3.03 to v3.07, and the hwOS
Sport firmware v10.57 to v10.63, the ppO2 divisor is sometimes not
correctly reset to zero when no ppO2 samples are being recorded.

Usually this condition can be detected by the fact that the length of
the extended sample will not have enough space left for the ppO2 sample
(9 bytes). As a workaround, reset the divisor back to zero to manually
disable the ppO2 samples.

In theory this detection method is not 100% reliable. There can still be
other sample types present in the extended sample. If their total size
is larger than 9 bytes, the bug will not be detected at all. Instead,
those bytes will get interpreted as the ppO2 sample, resulting in bogus
ppO2 values. Additionally, one of the other sample types will now run
out of space and cause the parsing to fail with an error. However, in
practice this risk is relative low. Most of the other samples are
relative small (1 or 2 bytes), so you would need many of them. That's
rather unlikely in most configurations. The only exception is the large
deco plan sample (15 bytes).
2019-11-22 22:59:25 +01:00
Jef Driesen
a5ba2f4e41 Use macros to encode the firmware version 2019-11-21 11:07:55 +01:00
Jef Driesen
612011249d Use symbolic constants for the sample types 2019-11-21 11:07:07 +01:00
Jef Driesen
b92cf6de69 Remove the obsolete hwos parameter
In commit 2829f7ebf9902170bf653d67dbe412a0a4f140cf, the hwos parameter
of the hw_ostc_parser_create() function was kept to preserve backwards
compatibility. Since the function has been removed from the public api,
the parameter can be removed now.
2019-11-21 11:07:07 +01:00
Jef Driesen
7f21998ad5 Limit the tank pressure workaround to hwOS devices
The workaround for the tank pressure in the previous commit is only
relevant for the newer hwOS based devices, and not for the original OSTC
devices. In practice this doesn't cause any problems because the
original OSTC doesn't support a tank pressure sensor, but nevertheless
it's better to use the correct condition.
2019-11-21 11:07:04 +01:00
Jef Driesen
ab230fd4e0 Fix the OSTC tank pressure decoding
The tank pressure is stored with a resolution of 1 bar instead of 0.1
bar. There is however one exception. The hwOS Sport firmware used a
resolution of 0.1 bar between versions 10.40 and 10.50.

Unfortunately the only way to distinguish the Sport from the Tech
variant is the different range of the version number (10.x vs 3.x). The
consequence is that this workaround will start to produce wrong results
once the firmware version number of the hwOS tech variant reaches the
10.x range. If that ever happens, this workaround should be removed
again!
2019-11-14 12:18:09 +01:00
Jef Driesen
21a9fa6879 Fix the Scubapro G2 HUD udev rule
The USB VID/PID numbers must not include the hexadecimal 0x prefix.
2019-11-14 10:06:50 +01:00
Jef Driesen
4bbcb6a8a1 Add the Mares Genius to the bluetooth filter
Use the prefix matcher because the bluetooth device name of the Mares
Genius appears to contain spaces at the end.
2019-11-14 10:06:39 +01:00
Jef Driesen
4c91309c56 Add firmware upgrade support for the Ratio computers 2019-11-14 09:43:35 +01:00
Linus Torvalds
426a39fc73 Merge upstream git://github.com/libdivecomputer/libdivecomputer
Merge misc fixes from Jef's upstream.

This fixes the incorrect and partial Oceanic Geo 4.0 support from commit
e38406b353bb ("Start adding IDs for the Oceanic Geo 4.0"), where I was
assuming it looked like the I770R.

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Oceanic Geo 4.0
  Fix a buffer overflow
2019-10-24 05:55:35 -04:00
Jef Driesen
e215d10296 Add support for the Oceanic Geo 4.0 2019-10-23 09:09:59 +02:00
Jef Driesen
e2ae5f9525 Fix a buffer overflow
There are 8 opening/closing records instead of 7.
2019-10-22 20:58:50 +02:00
Linus Torvalds
d3ccb88a44 Merge git://github.com/libdivecomputer/libdivecomputer.git into Subsurface-NG
Merge upstream updates from Jef Driesen:

 - clean up Shearwater tank pressure handling

 - minor fixlets

The Shearwater pressure sensor changes by Jef means that I also changed
how we handle the battery level for the pressure sensors, and integrated
it with the tank handling.

* jef/master:
  Improve the support for multiple tank transmitters
  Extract the log version immediately
  Use a struct for the gasmix data
  Use a prefix match for the Suunto bluetooth name
  Update the Shearwater Nerd bluetooth names
  Check condition before entering the loop
2019-10-13 11:19:08 -07:00
Jef Driesen
a7edb159fd Merge branch 'shearwater' 2019-09-27 08:07:50 +02:00
Jef Driesen
6c441bb402 Improve the support for multiple tank transmitters
Some of the newer Shearwater dive computers support up to 2 tank
pressure sensors. The tank pressure samples were already reported, but
the tank field with the corresponding begin/end pressure was still
missing.
2019-09-27 08:07:15 +02:00
Jef Driesen
e23c374cd8 Extract the log version immediately
To be able to collect the tank begin/end pressure, the log version needs
to be available earlier, because it's needed for parsing the tank
pressure data in the samples. Therefore, extract the log version
immediately after locating the opening record.
2019-09-24 14:00:25 +02:00
Jef Driesen
03ff5d32f2 Use a struct for the gasmix data 2019-09-24 14:00:01 +02:00
Jef Driesen
41b24adfcb Use a prefix match for the Suunto bluetooth name
The Suunto D5 bluetooth device name contains the serial number. Thus we
need to match only the prefix, instead of the full name.
2019-09-11 08:51:05 +02:00
Jef Driesen
ffeb6b2447 Update the Shearwater Nerd bluetooth names
Add the Shearwater Nerd 2 bluetooth device name.

The change to uppercase is purely cosmetic. The string comparisions are
not case-sensitive. But for documentation purposes it's good practice to
list the exact name as reported by the device.
2019-09-11 08:51:00 +02:00
Jef Driesen
f801b512c3 Check condition before entering the loop
The condition doesn't change inside the loop, so there is no need to
check it every iteration.
2019-09-11 08:50:16 +02:00
Linus Torvalds
ce6d9896a7 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef:

 - Jef took my i200C support patch, so merge that up (only difference
   was that we mark it as BLE-capable)

 - support for multiple cylinders and transmitters for the Ratio iDive
   dive computers

 - Fix Mares BLE packet cache missed invalidation

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Discard the cached BLE packet
  Add support for Aqualung i200c
  Take the tank transmitter flags into account
  Add support for multiple tank transmitters
  Use a struct for the gasmix and tank data
v4.9.3
2019-09-07 09:40:10 -07:00
Jef Driesen
912eb37ac3 Discard the cached BLE packet
When using a BLE connection, it's not sufficient to purge the buffers of
the underlying I/O stream. The locally cached BLE packet needs to be
discarded also.
2019-09-06 09:04:23 +02:00
Linus Torvalds
d62674a803 Add support for Aqualung i200c
It's exactly the same as the regular i200, but has a new version number
and string.

Tested-by: Tiago Thedim Dias <tiagotsoc@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-09-03 08:40:10 +02:00
Jef Driesen
d21070ad1a Merge branch 'ix3m-transmitter' 2019-09-02 08:27:21 +02:00
Jef Driesen
8829619473 Take the tank transmitter flags into account
Suppress the tank pressure sample when there is no active transmitter
available, or the connection with the transmitter is (temporary) lost.
In the latter case, the pressure is recorded as zero.
2019-09-02 08:26:38 +02:00
Jef Driesen
dc508c30f9 Add support for multiple tank transmitters
The Ratio dive computers support up to 10 tank pressure sensors. The ID
of the active tank sensor is stored in the sample data, and gets mapped
to the corresponding tank index.
2019-09-02 08:25:17 +02:00
Linus Torvalds
2d40cf46b1 Deepblu Cosmiq+: flesh out some of the comments and fingerprint size
I've tried to find where the firmware version and serial number are, and
have failed miserably.  Some of the commands I have sent instead cleared
the memory of the dive computer.  Whee.

But let's document the responses to the commands anyway, and flesh out
the fingerprinting code (which is useless without a device ID, which we
do not currently have).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 13:45:34 -07:00
Linus Torvalds
d532be187a Deepblu Cosmiq+: stop downloading once we've seen the dives already
.. and also support cancellation of dive downloading in the middle.

The Cosmiq+ doesn't remember all that many dives, but BLE is slow and
there's no point in downloading more than necessary.

I'll look at fingerprinting next, so that we can avoid downloading the
profile data if we have already seen the header.  That's a further small
optimization.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 12:19:32 -07:00
Linus Torvalds
df7aeeef01 Deepblu Cosmiq+: fix oxygen percentage reporting
When I added more parsing of the dive data of the Cosmiq+ in commit
4dff291a1a53 ("Deepblu Cosmiq+: fill in some parsing details") I got the
gasmix units completely wrong and clearly never tested it.

The DC_FIELD_GASMIX reporting uses floating point percentages, not
integer percentages, and instead of reporting 21% as 0.21, we used to
report it as 21.0.  It all looked fine in my profiles, because I'd only
tested simulated air dives, and subsurface defaults to air even if
somebody reports crazy impossible gases.

Easy enough to fix, and now actually tested by doing a simulated nitrox
dive.

Reported-by: Michael Werle <mwerle@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 11:58:08 -07:00
Jef Driesen
1cd285a4d8 Use a struct for the gasmix and tank data
This small refactoring is mainly a preparation to support multiple
tanks. There is no functional change.
2019-08-27 14:01:50 +02:00
Linus Torvalds
aab3d7a68e Add support for Aqualung i200c
It's exactly the same as the regular i200, but has a new version number
and string.

Tested-by: Tiago Thedim Dias <tiagotsoc@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
v4.9.2
2019-08-24 13:39:01 -07:00
Linus Torvalds
32e6ae4efa Deepblu Cosmiq+: fix missing prototype
Apparently I never added the new deepblu.h header file to the parser,
and never noticed.

But then Travis complains on the iOS build. Good catch, Travis.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-19 12:39:08 -07:00
Linus Torvalds
ccef003d47 Deepblu Cosmiq+: add progress reporting for downloading
Note that the fingerprinting code hasn't been connected yet (I'm n ot
entirely sure what I should compare - the whole 36-byte dive header?),
and it currently always downloads all dives on the Cosmiq+.

Not that that much matters, since there aren't all that many dives that
fit on it, but it's worth pointing out the current weaknesses of the
code.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 14:29:02 -07:00
Linus Torvalds
4dff291a1a Deepblu Cosmiq+: fill in some parsing details
This adds support for the different modes (scuba/gauge/freedive) and
teaches the parser to set the right sample interval and get the dive
time right.

In freedive mode, the sample interval is 1s, and the dive time is in
seconds too.  In the other modes, the sample interval is 20s, and the
divetime is in minutes.

Also set the right gas for scuba.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 13:50:50 -07:00
Linus Torvalds
eacfe4011a Deepblu Cosmiq+: add basic dive information parsing
This at least approximates downloading a dive from the Deepblu Cosmiq+,
and gives reasonable profiles for my test-dives (in a dive computer
chamber, not real dives).

I'm sure there's a lot to be improved here, and this literally only gets
depth and water temperature, but that seems to be what the Cosmiq+ gives
us.

Lots of credit to Michael Werle for bluetooth packet captures, and some basic analysis of the protocol.

Packet-logging-by: Michael Werle <mwerle@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-17 15:06:16 -07:00
Linus Torvalds
2efa83eeee Deepblu Cosmiq+: start downloading dive data
This actually seems to download all the data.  It just doesn't parse any
of it yet, so you get just empty dives.  But the basic packet and data
transfer seems to work.

Now I need to fill in the details on the actual dive parsing side, and I
should see a profile.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-17 11:53:25 -07:00
Linus Torvalds
4ce0ae9e4f Deepblu: add basic send/receive functionality
This was tested with a command to set the time and date, but only the
actual IO parts are here.

The packet format is fairly simple, even if it's not exactly clear why
everything is HEX-encoded.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-16 14:09:28 -07:00
Linus Torvalds
9812bf0828 Deepblu Cosmiq+: Add skeleton code
This does nothing at all, but it adds all the core skeleton
infrastructure for the Deepblu Cosmiq+ dive computer.

Let's see if I can make sense of things and make it download anything.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-15 14:46:38 -07:00
Linus Torvalds
ffbb472975 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef:

 - Add support for the Aqualung i550C

 - Update Ratio iX3M GPS naming and note that they support rfcomm

 - misc cleanups

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Aqualung i550C
  Enable bluetooth support for the Ratio iX3M GPS
  Update the naming of the Ratio iX3M GPS range
  Mark the string tables as constant
  Refactor the filter functions
v4.9.1 v4.9.0
2019-07-14 17:34:38 -07:00
Janice McLaughlin
d5aa15c1c5 Add support for the Aqualung i550C 2019-07-08 08:49:14 +02:00
Jef Driesen
07dff48a3b Enable bluetooth support for the Ratio iX3M GPS 2019-07-05 11:39:06 +02:00