From 406dbf3daee76b1d1fc49a9d028a2d9ff0934022 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 23 Jul 2016 15:32:50 +0900 Subject: [PATCH] Add severity indication to the event flags for the Suunto EON Steel This way Subsurface can show different icons depending on what kind of event we report. This also fixes a bug where the begin/end marker was mistakenly added as the value instead of as flag. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- include/libdivecomputer/parser.h | 5 ++++- src/suunto_eonsteel_parser.c | 28 +++++++++------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 4f16e87..626ebee 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -106,9 +106,12 @@ typedef enum parser_sample_event_t { typedef enum parser_sample_flags_t { SAMPLE_FLAGS_NONE = 0, SAMPLE_FLAGS_BEGIN = (1 << 0), - SAMPLE_FLAGS_END = (1 << 1) + SAMPLE_FLAGS_END = (1 << 1), + SAMPLE_FLAGS_SEVERITY_MASK = (7 << 2), } parser_sample_flags_t; +#define SAMPLE_FLAGS_SEVERITY_SHIFT 2 + typedef enum parser_sample_vendor_t { SAMPLE_VENDOR_NONE, SAMPLE_VENDOR_UWATEC_ALADIN, diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 9b48005..2be21cf 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -678,21 +678,6 @@ static const char *lookup_enum(const struct type_desc *desc, unsigned char value /* * The EON Steel has four different sample events: "state", "notification", * "warning" and "alarm". All end up having two fields: type and a boolean value. - * - * The type enumerations are available as part of the type descriptor, and we - * *should* probably parse them dynamically, but this hardcodes the different - * type values. - * - * For event states, the types are: - * - * 0=Wet Outside - * 1=Below Wet Activation Depth - * 2=Below Surface - * 3=Dive Active - * 4=Surface Calculation - * 5=Tank pressure available - * - * FIXME! This needs to parse the actual type descriptor enum */ static void sample_event_state_type(const struct type_desc *desc, struct sample_data *info, unsigned char type) { @@ -710,8 +695,9 @@ static void sample_event_state_value(const struct type_desc *desc, struct sample sample.event.type = SAMPLE_EVENT_STRING; sample.event.name = name; + sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; + sample.event.flags |= 1 << SAMPLE_FLAGS_SEVERITY_SHIFT; - sample.event.value = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); } @@ -733,8 +719,9 @@ static void sample_event_notify_value(const struct type_desc *desc, struct sampl sample.event.type = SAMPLE_EVENT_STRING; sample.event.name = name; + sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; + sample.event.flags |= 2 << SAMPLE_FLAGS_SEVERITY_SHIFT; - sample.event.value = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); } @@ -755,8 +742,9 @@ static void sample_event_warning_value(const struct type_desc *desc, struct samp sample.event.type = SAMPLE_EVENT_STRING; sample.event.name = name; + sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; + sample.event.flags |= 3 << SAMPLE_FLAGS_SEVERITY_SHIFT; - sample.event.value = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); } @@ -778,7 +766,9 @@ static void sample_event_alarm_value(const struct type_desc *desc, struct sample sample.event.type = SAMPLE_EVENT_STRING; sample.event.name = name; - sample.event.value = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; + sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; + sample.event.flags |= 4 << SAMPLE_FLAGS_SEVERITY_SHIFT; + if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); }