Since we can now parse FIT files from other vendors than Garmin (ie the
Suunto FIT file export), let's expose this as a generic "FIT file
import" in the dive computer list.
It's all still very much using the Garmin parser, but uses a model ID
that is zero. The only difference that makes is that it also tells the
parser to treat the result as a dive even if it cannot find the actual
dive markers that Garmin uses, since those won't exist in the limited
FIT file export.
This is still somewhat inconvenient, in that you cannot point to the
file itself, you can just point to the directory that contains FIT
files. And right now we have an artifical length limitation on the
filenames, but I'll fix that next.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
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>
We explicitly check that field for 0 before dereferencing it. Let's make sure
that it always starts out being 0 - otherwise we'll get a potential crash here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the caller provides us with a path name, we should not try to connect to the
dive computer via MTP, but instead read the .FIT files from the path provided.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create parallel helper functions that use libmtp to walk the file tree on the
device and to then read a specific file from the device into our dc_buffer.
MTP is not a file system, it's an object storage, that just happens to allow
object names and parent/child relationships between objects. As a result we
need to remember those file ids for MTP downloads.
The mtp_get_file_list function is rather complex as it includes both the
initial communication with the device and the code to walk the object tree and
then create the list of file.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Breaking things into helper function makes it much easier to then support both
regular file operations and MTP.
This includes some mild whitespace cleanups for consistency.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We do this for a few other device where we need slightly different behavior,
depending on the specific model.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This uses pretty much all of our new infrastructure: the USB storage
iostream for the actual IO, the field-cache for the divecomputer fields,
and the string interface for the events.
It's also a very fast downloader.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>