From 8fb4018db3cb43571e20e1e7075c1f196973cee3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 21 Jul 2016 19:43:27 +0900 Subject: [PATCH] Suunto EON Steel: add transmitter battery state reporting I'm not sure how reliable it is, and older wireless tank pods had a bug in the reporting (looks like the battery voltage range calibration was done incorrectly, and it reports 0% battery for new batteries). But depending on how well it actually works when the batteries start getting weak, the transmitter battery reporting is potentially *very* useful. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- src/suunto_eonsteel_parser.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index dd75d9d..9b48005 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -1292,6 +1292,21 @@ static int traverse_gas_fields(suunto_eonsteel_parser_t *eon, const struct type_ if (!strcmp(name, ".Gas.TankFillPressure")) return add_gas_workpressure(eon, get_le32_float(data)); + // There is a bug with older transmitters, where the transmitter + // battery charge returns zero. Rather than returning that bogus + // data, just don't return any battery charge information at all. + // + // Make sure to add all non-battery-charge field checks above this + // test, so that it doesn't trigger for anything else. + if (!data[0]) + return 0; + + if (!strcmp(name, ".Gas.TransmitterStartBatteryCharge")) + return add_string_fmt(eon, "Transmitter Battery at start", "%d %%", data[0]); + + if (!strcmp(name, ".Gas.TransmitterEndBatteryCharge")) + return add_string_fmt(eon, "Transmitter Battery at end", "%d %%", data[0]); + return 0; }