From 48b03a977aff2de4532930e4d84f25606d4e7074 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 May 2019 02:24:37 -0700 Subject: Decode attribute values --- .../traccar/protocol/SuntechProtocolDecoder.java | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index bd485ca70..1ad984c60 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -326,12 +326,28 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { case "UEX": int remaining = Integer.parseInt(values[index++]); while (remaining > 0) { - String value = values[index++]; - String[] pair = value.split("="); + String attribute = values[index++]; + String[] pair = attribute.split("="); if (pair.length >= 2) { - position.set(pair[0].toLowerCase(), pair[1].trim()); + String value = pair[1].trim(); + if (value.contains(".")) { + value = value.substring(0, value.indexOf('.')); + } + switch (pair[0].charAt(0)) { + case 't': + position.set(Position.PREFIX_TEMP + pair[0].charAt(2), Integer.parseInt(value, 16)); + break; + case 'N': + position.set("fuel" + pair[0].charAt(2), Integer.parseInt(value, 16)); + break; + case 'Q': + position.set("drivingQuality", Integer.parseInt(value, 16)); + break; + default: + break; + } } - remaining -= value.length() + 1; + remaining -= attribute.length() + 1; } break; default: -- cgit v1.2.3