1612 Commits

Author SHA1 Message Date
Dirk Hohndel
4d8cdaaf8e Garmin: attempt to parse big endian .FIT files
The only examples I have seen so far are small incomplete files that
don't contain the dive profile, so I'm unsure if this is sufficient (and
why there are big endian files in the first place).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-06 13:27:26 -07:00
Michael Andreen
565bb2af02 Garmin: Don't require sub directories for fit files
Start looking for fit files in the normal Garmin/Activity sub directory,
but if that doesn't exist look directly in the specified directory.

Signed-off-by: Michael Andreen <michael@andreen.dev>
2022-08-02 22:20:24 +02:00
Linus Torvalds
107f5b14e3 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream changes from Jef Driesen:

 - New dive computer support:
    - Ratio iX3M 2
    - Sherwood Amphos Air 2.0

 - Cleanups and fixes

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Ratio iX3M 2 models
  Add support for the Sherwood Amphos Air 2.0
  Replace switch statements with an array lookup
  Add Shearwater Perdix 2 and Petrel 3
  Update the Shearwater hardware IDs
  Fix the clock synchronization
  Remove unused time parameters
  Add support for a new Aqualung i200C variant
2022-07-30 17:18:51 -07:00
Jef Driesen
391d4db419 Add support for the Ratio iX3M 2 models
The protocol and data structures have not changed, so just adding the
new names and model numbers.
2022-07-22 00:27:30 +02:00
Jef Driesen
972beb52be Add support for the Sherwood Amphos Air 2.0
The Amphos Air 2.0 appears to be identical to the previous Amphos Air,
except for the new model number and version string.
2022-07-15 22:14:33 +02:00
Jef Driesen
80f22dce0b Replace switch statements with an array lookup
No functional change, just some more compact code.
2022-07-15 22:11:24 +02:00
Dirk Hohndel
26c43d6d8b Add Shearwater Perdix 2 and Petrel 3
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-27 15:08:35 +02:00
Dirk Hohndel
8451286c17 Update the Shearwater hardware IDs
Update and fix the hardware IDs based on the latest information from
Shearwater.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-27 15:02:51 +02:00
Jef Driesen
be5bb9e690 Fix the clock synchronization
For dives with a timestamp that is larger than the current device time
(e.g. in the future), the clock synchronization produces incorrect
values. In that case, the time difference suddenly becomes negative,
which corresponds to a large positive value as an unsigned integer.

Under normal circumstances, this scenario can't happen. But sometimes
actions such as battery replacements or firmware upgrades can cause the
internal clock to reset.

The Reefnet devices shouldn't need this fix, because their internal
clock can't be changed, but it doesn't hurt either.
2022-06-23 15:57:08 +02:00
Jef Driesen
e6f091909b Remove unused time parameters
Since the clock synchronization has been removed (see commit
a1962558412b8c89a79656992c8e7f4d001065c2 for the details), those
parameters serve no purpose anymore.
2022-06-23 15:56:10 +02:00
Jef Driesen
4616e2ed21 Add support for a new Aqualung i200C variant
There is a new variant of the i200C with a different model number
(0x4749) and double the amount of memory (128K).
2022-06-19 20:56:14 +02:00
Dirk Hohndel
a17e466bd1 Add Shearwater Perdix 2 and Petrel 3
Also update and fix the hardware IDs based on the latest information
from Shearwater.
Two of the hardware IDs that we supported before are not listed in the
current docs. In an abundance of caution I'll leave them in the code.
No harm done if they don't exist in real life.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-14 14:17:51 -07:00
Dirk Hohndel
643a6211b2 Simplistic attempt to support new Aqualung i200C
There appear to be newer models in the wild with a different model
number, but labeled as i200C.

To avoid confusion, this calls the new model i200Cv2.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-14 16:32:08 +00:00
Linus Torvalds
aff0c28d08 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge Jef's upstream updates:

 - Add support for Seac Screen and Action

 - Add support for Cressi Michelangelo

 - misc small fixes

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Seac Screen and Action
  Add an address parameter to the memory dump helper function
  Ignore invalid gas mixes
  Add support for the Cressi Michelangelo
  Move the C_ARRAY_SIZE macro to a common place
  Fix the timezone offset in the xml output
  Emit a devinfo event when downloading a memory dump
  Read the info and more info data during startup
  Use helper functions to decode multibyte values
  Fix changing the OSTC settings
2022-06-05 09:02:06 -07:00
Jef Driesen
4b4efb2c07 Add support for the Seac Screen and Action 2022-06-02 11:29:32 +02:00
Jef Driesen
2443d3ea47 Add an address parameter to the memory dump helper function
To support devices where not all memory is readable, the memory dump
helper function needs an extra parameter to specify the start address.
2022-06-01 13:27:13 +02:00
Jef Driesen
d0c7562c41 Ignore invalid gas mixes
The Cressi Michelangelo appears to store inactive gas mixes as a zero
oxygen percentage. Such invalid values shouldn't be reported.
2022-06-01 09:16:23 +02:00
Dirk Hohndel
7c3e92e391 move pointer test to generic helper
This should always be tested for - the only other user of the generic
helper currently didn't test for it, either.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-05-31 14:46:30 -07:00
Dirk Hohndel
0aad8cfd13 Garmin: replace get_field function
The generic function already handles all the cases (treating gasmix and
tank count as being the same and responding UNSUPPORTED to the same set
of types). The only thing missing is the check of the value parameter
and the extraction of the cache pointer from the context.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-05-31 14:46:28 -07:00
Dirk Hohndel
cd72516668 Garmin: decode divemode
The code used sub_sport to figure out if this was a dive in the first
place, but then never reported back the specific dive mode, leading to
all dives being interpreted as open circuit.

Reported-By: Anton van Rosmalen
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-05-31 10:59:45 -07:00
Jef Driesen
0064097c03 Add support for the Cressi Michelangelo
The Cressi Michelangelo appears to be compatible with the Goa, with just
a different model number.
2022-05-23 12:54:44 +02:00
Jef Driesen
8bfb965589 Move the C_ARRAY_SIZE macro to a common place 2022-05-23 12:14:00 +02:00
Jef Driesen
4512a0a5d7 Emit a devinfo event when downloading a memory dump
For diagnostics purposes it's often very useful to have the device
information available when downloading a memory dump.
2022-05-23 12:01:42 +02:00
Jef Driesen
52d2684479 Read the info and more info data during startup 2022-05-23 12:01:38 +02:00
Jef Driesen
7e3bf7eeb8 Use helper functions to decode multibyte values
Add and use some helper functions for decoding multibyte BCD and binary
encoded values, to remove some code duplication.
2022-05-23 12:00:35 +02:00
Michael Andreen
ea051578e6 Garmin: Handle file names in short format
When downloading heart rate data from a chest strap the Descent MK2i
uses a more compact format, like C4ND0302.fit. If any such dives have
been downloaded then newer dives in long format won't be detected and
requires downloading all dives and picking the right ones.

Instead parse this short format and ensure that these dives end up in
the correct order.

Format information found here:
https://gist.github.com/waywardone/fa8cb01462790aa8a26fab97477b80e1

Signed-off-by: Michael Andreen <michael@andreen.dev>
2022-04-24 23:54:04 +02:00
Linus Torvalds
77498afe5e Merge github.com:libdivecomputer/libdivecomputer into Subsurface-DS9
Pull upstream fix for Genesis React Pro serial number from Jef.

* github.com:libdivecomputer/libdivecomputer:
  Fix the Genesis React Pro serial number
2022-04-04 11:34:30 -07:00
Michael Andreen
5f3a0f0b8a OSTC: Use deco model instead of dive mode for deco model information
In the most recent merge deco model (byte 79) was swapped for divemode
(byte 82). This caused all OC dives to be classified as the older
algorithm without gradient factors.

Signed-off-by: Michael Andreen <michael@andreen.dev>
2022-04-03 23:49:07 +02:00
Jef Driesen
0753f10661 Fix changing the OSTC settings
The command to change the OSTC settings has a variable length payload (1
to 4 bytes). Therefore, the expected number of bytes is only know after
evaluating the first option index byte. Due to the limited UART buffer
in the OSTC, sending the remainder of the packet immediately after the
first byte, can cause the OSTC to get out of sync.

Introduce a small delay between sending the option index and the
remaining parameters to avoid this problem.
2022-03-31 13:20:13 +02:00
Nick Shore
0448ce686a Fix the Genesis React Pro serial number 2022-03-27 10:51:08 +02:00
Linus Torvalds
39dbb275cc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge Jef's upstream into the Subsurface branch:

 - support for new dive computers: Mares Pick Pro+, Deep Six Excursion,
   Crest CR-4, Genesis Centauri and Tusa TC1.

 - support freedive mode on Mares Smart Air

 - work with Oceanic dive computers regardless of whether they need the
   BLE handshake or not

 - OSTC updates: support bigger BLE packets in newer versions, fix
   setpoint in SCR mode

 - Shearwater updates: full dive mode parsing, correct timezone handling
   on Teric, support up to four transmitters on newer log versions.

* git://github.com/libdivecomputer/libdivecomputer: (26 commits)
  Read the extra tank information
  Add support for transmitter T3 and T4
  Limit the number of records for the Predator
  Report the timezone offset for the Teric
  Use the correct model number from the final block
  Use the dive mode stored in the header
  Report the correct dive mode for SCR dives
  Increase the size of the BLE packet cache
  Add support for the Genesis Centauri and Tusa TC1
  Read the hardware and software version
  Report the initial setpoint in SCR mode
  Add the divemode to the layout descriptor
  Re-order the fields in the layout descriptor
  Show the correct help message for the scan command
  Add support for the Crest CR-4
  Add udev rule for the Suunto EON Steel Black
  Ignore unsupported BLE handshake
  Detect NAK response packets
  Remove the initial gas switch
  Restore the original standard gravity factor
  ...
2022-02-27 12:20:09 -08:00
Jef Driesen
c6640aa7d3 Read the extra tank information
The latest firmware does store some additional information for each
tank. Right now it's not really used for anything yet, but it's
available for future use.
2022-02-27 11:49:53 +01:00
Jef Driesen
7a650f940c Add support for transmitter T3 and T4
In recent firmware versions (log version 13), Shearwater added support
for two more tank transmittors: T3 and T4.
2022-02-27 11:48:41 +01:00
Jef Driesen
86e1d59a6a Limit the number of records for the Predator
In the older Predator-like data format, the 4th opening/closing record
is the last one. To avoid accidental use of the higher ones, leave them
undefined.
2022-02-27 11:47:13 +01:00
Jef Driesen
54fa676e75 Report the timezone offset for the Teric
The Shearwater Teric supports a UTC offset and DST setting.
2022-02-27 11:46:51 +01:00
Jef Driesen
d1242a28cf Use the correct model number from the final block
During the download, the model number is obtained from the hardware type
because the model number isn't available before downloading the first
dive. Since the list with available hardware types is incomplete, the
correct model number is not always available. However, during parsing
the correct model number is available in the final block.
2022-02-27 11:45:26 +01:00
Jef Driesen
ccd37d4fa3 Use the dive mode stored in the header
Starting with log version 8, the dive mode is stored in one of the
opening records. For backwards compatibility with older firmware
versions, the autodetection based on the status field in the sample data
is kept as a fallback mechanism.
2022-02-27 11:44:58 +01:00
Jef Driesen
811a9b4f89 Report the correct dive mode for SCR dives
The status field contains an extra bit for SCR dives, so there is no
reason to report them as CCR dives.
2022-02-18 13:54:22 +01:00
Jef Driesen
2794f96e47 Increase the size of the BLE packet cache
In the latest OSTC hardware, the Telit/Stollman bluetooth module has
been replaced with a u-Blox Nina B2 bluetooth module. This new module
supports BLE data packets of up to 244 bytes (corresponding to an ATT
MTU of 247 bytes and a LL PDU payload size of 251 bytes).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-02-14 12:39:40 -08:00
Jef Driesen
d960a37e12 Increase the size of the BLE packet cache
In the latest OSTC hardware, the Telit/Stollman bluetooth module has
been replaced with a u-Blox Nina B2 bluetooth module. This new module
supports BLE data packets of up to 244 bytes (corresponding to an ATT
MTU of 247 bytes and a LL PDU payload size of 251 bytes).
2022-01-31 14:06:17 +01:00
Jef Driesen
17bc0faa51 Restore the original standard gravity factor
The Uwatec/Scubapro dive computers are confirmed to internally use the
approximated standard gravity (10.0 m/s²) for the depth conversion.
Allthough this is technically wrong, users expect to get the same depth
values as their dive computer shows.

This partially reverts commit cfc9ddc380bdc5616893fc2af4e05204b5500ea2.
2022-01-10 13:40:13 -08:00
Jef Driesen
f6df075d51 Add support for the Genesis Centauri and Tusa TC1
Both models are compatible with the Deep Six Excursion.
2022-01-03 16:09:37 +01:00
Jef Driesen
c5dced237a Read the hardware and software version 2022-01-03 15:58:33 +01:00
Jef Driesen
5e2d376627 Report the initial setpoint in SCR mode 2022-01-03 15:54:49 +01:00
Jef Driesen
16e49eee6d Add the divemode to the layout descriptor 2022-01-03 15:54:49 +01:00
Jef Driesen
70411048e5 Re-order the fields in the layout descriptor
The new order of the fields matches the physical memory layout more
closely.
2022-01-03 15:54:39 +01:00
Jef Driesen
af03e39383 Add support for the Crest CR-4
The Crest CR-4 is compatible with the Deep Six Excursion.
2021-11-19 08:26:19 +01:00
Michael Andreen
93fe31eef5 Garmin: Fix gas change event parsing
The gas mixes are numbered from 0 and up and the gas change event uses
this number directly, so no need to subtract one.

Signed-off-by: Michael Andreen <michael@andreen.dev>
2021-11-17 11:58:14 +01:00
Jef Driesen
cd0f42804a Ignore unsupported BLE handshake
For some BLE enabled models, like the Oceanic Pro Plus X, Aqualung
i750TC, Sherwood Sage and Sherwood Beacon, the BLE handshake command
is not supported and therefore disabled.

However, based on a bug report by a user with two Aqualung i770R dive
computers, this detection mechanism based on the dive computer model
number isn't sufficient. Allthough the two devices have the exact same
firmware version (2A), the handshake command only works on the newest
unit, and fails with a NAK response on the oldest unit.

Remove the model based detection and always try to send the handshake
command and rely on the NAK response to ignore the failure instead. An
additional advantage is that we no longer have to (manually) maintain a
list with the model numbers where the handshaking is known to fail.
2021-10-20 15:02:57 +02:00
Jef Driesen
ba4a119a4f Detect NAK response packets
When the dive computer receives a command it doesn't support, it sends
back a single byte NAK (0xA5) packet instead of the expected ACK byte
(0x5A) at the start of the packet. Retrying is pointless in this case,
because the next attempt will also fail. Instead, return immediately
with an appropriate error code, and let the upper layers handle the
unsupported command.

Note that the detection is currently only enabled for BLE communication.
2021-10-20 15:02:34 +02:00