diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-08 09:49:06 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-08 09:49:06 +1300 |
commit | b89c936b9ffb0bb3eda36830dba7a6870bbc86c5 (patch) | |
tree | 1998b4dcea51cf12628824a73e7546e97f686c8a /src/org/traccar | |
parent | 77158ade988919ce63c905f8328dc6af2ac097c3 (diff) | |
download | traccar-server-b89c936b9ffb0bb3eda36830dba7a6870bbc86c5.tar.gz traccar-server-b89c936b9ffb0bb3eda36830dba7a6870bbc86c5.tar.bz2 traccar-server-b89c936b9ffb0bb3eda36830dba7a6870bbc86c5.zip |
Decode GL200 status field
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 605add0d5..574f9a8c3 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -22,6 +22,7 @@ import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; +import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -148,7 +149,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(x+)?,") // adc 1 .number("(x+)?,") // adc 2 .number("(d{1,3})?,") // battery - .number("(x{6})?,,,,") // device status + .number("(?:(xx)(xx)(xx))?,,,,") // device status .groupEnd() .number("(dddd)(dd)(dd)") // date .number("(dd)(dd)(dd)").optional(2) // time @@ -350,7 +351,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.PREFIX_ADC + 1, parser.next()); position.set(Event.PREFIX_ADC + 2, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); - position.set(Event.KEY_STATUS, parser.next()); + + if (parser.hasNext(3)) { + int ignition = parser.nextInt(16); + if (BitUtil.check(ignition, 4)) { + position.set(Event.KEY_IGNITION, false); + } else if (BitUtil.check(ignition, 5)) { + position.set(Event.KEY_IGNITION, true); + } + position.set(Event.KEY_INPUT, parser.nextInt(16)); + position.set(Event.KEY_OUTPUT, parser.nextInt(16)); + } // workaround for wrong location time if (parser.hasNext(6)) { |