diff --git a/examples/universal.c b/examples/universal.c index 1e0307b..c90fe5b 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -361,6 +361,21 @@ doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int fprintf (fp, "%02u:%02u\n", divetime / 60, divetime % 60); + // Parse the temperature. + message ("Parsing the temperature.\n"); + double temperature = 0.0; + rc = dc_parser_get_field (parser, DC_FIELD_TEMPERATURE, 0, &temperature); + if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { + WARNING ("Error parsing the temperature."); + dc_parser_destroy (parser); + return rc; + } + + if (rc != DC_STATUS_UNSUPPORTED) { + fprintf (fp, "%.1f\n", + temperature); + } + // Parse the maxdepth. message ("Parsing the maxdepth.\n"); double maxdepth = 0.0; diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 65b18c9..a1919a9 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -53,7 +53,8 @@ typedef enum dc_field_type_t { DC_FIELD_GASMIX_COUNT, DC_FIELD_GASMIX, DC_FIELD_SALINITY, - DC_FIELD_ATMOSPHERIC + DC_FIELD_ATMOSPHERIC, + DC_FIELD_TEMPERATURE } dc_field_type_t; typedef enum parser_sample_event_t {