diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-05-22 02:33:33 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-05-22 02:33:33 +1200 |
commit | d87982ac9af60b505b045e499615bc6859bd86c5 (patch) | |
tree | a5b3f5a5aa04c72805017d745d82f108b77c8bb2 | |
parent | c3f723397ff20562b1fc9ed385cb717084268ca6 (diff) | |
download | traccar-server-d87982ac9af60b505b045e499615bc6859bd86c5.tar.gz traccar-server-d87982ac9af60b505b045e499615bc6859bd86c5.tar.bz2 traccar-server-d87982ac9af60b505b045e499615bc6859bd86c5.zip |
Support GL300 input change messages
-rw-r--r-- | src/org/traccar/protocol/Gl200TextProtocolDecoder.java | 35 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 12 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java index 232f4cdfb..323d5cc45 100644 --- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -247,6 +247,21 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .text("$").optional() .compile(); + private static final Pattern PATTERN_LSW = new PatternBuilder() + .text("+RESP:").expression("GT[LT]SW,") + .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version + .number("(d{15}|x{14}),") // imei + .expression("[^,]*,") // device name + .number("[01],") // type + .number("([01]),") // state + .expression(PATTERN_LOCATION.pattern()) + .number("(dddd)(dd)(dd)") // date (yyyymmdd) + .number("(dd)(dd)(dd)").optional(2) // time (hhmmss) + .text(",") + .number("(xxxx)") // count number + .text("$").optional() + .compile(); + private static final Pattern PATTERN_IDA = new PatternBuilder() .text("+RESP:GTIDA,") .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version @@ -837,6 +852,22 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { return position; } + private Object decodeLsw(Channel channel, SocketAddress remoteAddress, String sentence) { + Parser parser = new Parser(PATTERN_LSW, sentence); + Position position = initPosition(parser, channel, remoteAddress); + if (position == null) { + return null; + } + + position.set(Position.PREFIX_IN + (sentence.contains("LSW") ? 1 : 2), parser.nextInt() == 1); + + decodeLocation(position, parser); + + decodeDeviceTime(position, parser); + + return position; + } + private Object decodeIda(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_IDA, sentence); Position position = initPosition(parser, channel, remoteAddress); @@ -1051,6 +1082,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { case "IGF": result = decodeIgn(channel, remoteAddress, sentence); break; + case "LSW": + case "TSW": + result = decodeLsw(channel, remoteAddress, sentence); + break; case "IDA": result = decodeIda(channel, remoteAddress, sentence); break; diff --git a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index 7d3fe8d53..7269c0b78 100644 --- a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -11,6 +11,18 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(new Gl200Protocol()); verifyPosition(decoder, buffer( + "+RESP:GTLSW,300500,860599002636595,,0,0,0,0.0,0,2886.5,-78.467145,-0.165335,20180518221815,,,,,,20180518221817,B6FD$")); + + verifyPosition(decoder, buffer( + "+RESP:GTLSW,300500,860599002636595,,0,1,0,0.0,0,2886.5,-78.467145,-0.165335,20180518221818,,,,,,20180518221819,B6FF$")); + + verifyPosition(decoder, buffer( + "+RESP:GTTSW,1A0100,135790246811220,,1,0,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20100214093254,11F0$")); + + verifyPosition(decoder, buffer( + "+RESP:GTLSW,1A0100,135790246811220,,0,1,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20100214093254,11F0$")); + + verifyPosition(decoder, buffer( "+RESP:GTIGF,270302,867162025085234,,3519,0,0.0,92,111.2,-116.867638,32.450321,20180327070835,0334,0020,2B24,52CC3DE,00,,243.1,20180327070837,2A98$")); verifyPosition(decoder, buffer( |