From e650acc0529b2f714699f95b21992deaa1638282 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 5 May 2019 09:57:36 -0700 Subject: [PATCH] Garmin: be more permissive about the activity type We used to require that we have one of the documented dive types in the 'sub_sport' type field. But apparently Garmin added a new type number for CCR diving, so CCR dives weren't recognized at all. Add the new CCR case, but also say that if we have seen a DIVE_SUMMARY record with average depth information, we'll just assume it's a dive even for unrecognized sub_sport numbers. Reported-by: Thomas Jacob Signed-off-by: Linus Torvalds --- src/garmin_parser.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/garmin_parser.c b/src/garmin_parser.c index 1b4aa04..ec80186 100644 --- a/src/garmin_parser.c +++ b/src/garmin_parser.c @@ -1253,7 +1253,22 @@ garmin_parser_is_dive (dc_parser_t *abstract, const unsigned char *data, unsigne devinfo_p->serial = garmin->cache.serial; devinfo_p->model = garmin->cache.product; } - return garmin->cache.sub_sport >= 53 && garmin->cache.sub_sport <= 57; + switch (garmin->cache.sub_sport) { + case 53: // Single-gas + case 54: // Multi-gas + case 55: // Gauge + case 56: // Apnea + case 57: // Apnea Hunt + case 63: // CCR + return 1; + default: + // Even if we don't recognize the sub_sport, + // let's assume it's a dive if we've seen + // average depth in the DIVE_SUMMARY record. + if (garmin->cache.AVGDEPTH) + return 1; + return 0; + } } static dc_status_t