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>