core: work around water temperature bug in Tecdiving DiveComputer.eu

It appears to send a first sample with a water temperature of 0 C. If the next
sample contains a more likely water temperature, overwrite the first one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2022-04-13 08:51:48 -10:00
parent 514edfec07
commit acc4dc57af
2 changed files with 9 additions and 0 deletions

View file

@ -831,6 +831,14 @@ static int dive_cb(const unsigned char *data, unsigned int size,
dive->dc.sample[0].temperature.mkelvin = 0;
}
/* special case for bug in Tecdiving DiveComputer.eu
* often the first sample has a water temperature of 0C, followed by the correct
* temperature in the next sample */
if (same_string(dive->dc.model, "Tecdiving DiveComputer.eu") &&
dive->dc.sample[0].temperature.mkelvin == ZERO_C_IN_MKELVIN &&
dive->dc.sample[1].temperature.mkelvin > dive->dc.sample[0].temperature.mkelvin)
dive->dc.sample[0].temperature.mkelvin = dive->dc.sample[1].temperature.mkelvin;
record_dive_to_table(dive, devdata->download_table);
return true;