Add support for Mares Smart Air freedives

The Mares Smart Air supports a freedive mode, which uses a different
data format compared to the scuba dives.
This commit is contained in:
Jef Driesen 2021-08-31 18:01:26 +02:00
parent e52468e0c3
commit 7e075eb959
2 changed files with 33 additions and 5 deletions

View File

@ -790,9 +790,15 @@ mares_iconhd_device_foreach_raw (dc_device_t *abstract, dc_dive_callback_t callb
samplesize = 14;
fingerprint = 0x40;
} else if (model == SMARTAIR) {
headersize = 0x84;
samplesize = 12;
fingerprint = 2;
if (mode == FREEDIVE) {
headersize = 0x30;
samplesize = 6;
fingerprint = 0x22;
} else {
headersize = 0x84;
samplesize = 12;
fingerprint = 2;
}
}
if (offset < headersize)
break;
@ -811,7 +817,7 @@ mares_iconhd_device_foreach_raw (dc_device_t *abstract, dc_dive_callback_t callb
// end of the ringbuffer. The current dive is incomplete (partially
// overwritten with newer data), and processing should stop.
unsigned int nbytes = 4 + headersize + nsamples * samplesize;
if (model == ICONHDNET || model == QUADAIR || model == SMARTAIR) {
if (model == ICONHDNET || model == QUADAIR || (model == SMARTAIR && mode != FREEDIVE)) {
nbytes += (nsamples / 4) * 8;
} else if (model == SMARTAPNEA) {
unsigned int settings = array_uint16_le (buffer + offset - headersize + 0x1C);

View File

@ -228,6 +228,18 @@ static const mares_iconhd_layout_t smart_freedive = {
UNSUPPORTED, /* tanks */
};
static const mares_iconhd_layout_t smartair_freedive = {
0x08, /* settings */
0x22, /* datetime */
0x0E, /* divetime */
0x1C, /* maxdepth */
0x1A, 1, /* atmospheric */
0x20, /* temperature_min */
0x1E, /* temperature_max */
UNSUPPORTED, /* gasmixes */
UNSUPPORTED, /* tanks */
};
static const mares_iconhd_layout_t genius = {
0x0C, /* settings */
0x08, /* datetime */
@ -338,7 +350,7 @@ mares_iconhd_cache (mares_iconhd_parser_t *parser)
headersize = 0x80;
samplesize = 12;
layout = &iconhdnet;
} else if (parser->model == QUADAIR || parser->model == SMARTAIR) {
} else if (parser->model == QUADAIR) {
headersize = 0x84;
samplesize = 12;
layout = &smartair;
@ -356,6 +368,16 @@ mares_iconhd_cache (mares_iconhd_parser_t *parser)
headersize = 0x50;
samplesize = 14;
layout = &smartapnea;
} else if (parser->model == SMARTAIR) {
if (mode == ICONHD_FREEDIVE) {
headersize = 0x30;
samplesize = 6;
layout = &smartair_freedive;
} else {
headersize = 0x84;
samplesize = 12;
layout = &smartair;
}
}
if (length < 4 + headersize) {