From 035deb166330dd7bf204a2acd2e8045317e0e440 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 1 Jun 2017 02:37:01 +1200 Subject: Add GV300 temperature sensor support --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 7e76fd6c9..a6da38ef4 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -217,7 +217,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(x+)?,") // adc 2 .number("(d{1,3})?,") // battery .number("(?:(xx)(xx)(xx))?,") // device status - .any() + .expression("(.*)") // additional data .number("(dddd)(dd)(dd)") // date (yyyymmdd) .number("(dd)(dd)(dd)").optional(2) // time (hhmmss) .text(",") @@ -601,6 +601,20 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { decodeStatus(position, parser); + int index = 0; + String[] data = parser.next().split(","); + if (data.length > 1) { + int deviceType = Integer.parseInt(data[index++]); + if (deviceType == 2) { + int deviceCount = Integer.parseInt(data[index++]); + for (int i = 1; i <= deviceCount; i++) { + index++; // id + index++; // type + position.set(Position.PREFIX_TEMP + i, Short.parseShort(data[index++], 16) * 0.0625); + } + } + } + decodeDeviceTime(position, parser); return positions; -- cgit v1.2.3