diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-04 05:19:40 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-04 05:19:40 +1200 |
commit | d0ed5e6964a5e44793b8c72106f09e4ce147f47d (patch) | |
tree | 65c5a8be33cb73ce24315cb63d6d35379af2b24b | |
parent | 9379a48aee811cf6fe467581778c07ee253c195f (diff) | |
download | trackermap-server-d0ed5e6964a5e44793b8c72106f09e4ce147f47d.tar.gz trackermap-server-d0ed5e6964a5e44793b8c72106f09e4ce147f47d.tar.bz2 trackermap-server-d0ed5e6964a5e44793b8c72106f09e4ce147f47d.zip |
Support CK300 device protocol
-rw-r--r-- | src/org/traccar/protocol/Gl200TextProtocolDecoder.java | 18 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java index e05182022..988fd71c8 100644 --- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -80,7 +80,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .number("d{14},") // last fix time .groupBegin() .number("(d+),") // battery percentage - .expression("[01]?,") // flash type + .number("[d.]*,") // flash type / power .number("(-?[d.]+)?,,,") // temperature .or() .expression("(?:[01])?,").optional() // pin15 mode @@ -394,7 +394,21 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { return null; } - position.set(Position.KEY_STATUS, parser.next()); + String status = parser.next(); + + if (status.charAt(0) == '2') { + position.set(Position.KEY_IGNITION, true); + } else if (status.charAt(0) == '4') { + position.set(Position.KEY_IGNITION, false); + } + + if (status.charAt(1) == '1') { + position.set(Position.KEY_MOTION, false); + } else if (status.charAt(1) == '2') { + position.set(Position.KEY_MOTION, true); + } + + position.set(Position.KEY_STATUS, status); position.set(Position.KEY_RSSI, parser.nextInt()); diff --git a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index cb515a73e..812973fb8 100644 --- a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(new Gl200Protocol()); + verifyAttributes(decoder, buffer( + "+RESP:GTINF,210102,354524044950583,,42,89011702272048900184,11,99,0,,,4.08,0,1,1,0,0,20170831170831,87,0.00,,,,20170831171010,0064$")); + verifyPosition(decoder, buffer( "+RESP:GTOBD,360701,864251020253807,LSGTC58UX7Y067312,GV500,0,70FFFF,LSGTC58UX7Y067312,1,12309,983A8140,0,0,33,nan,,0,0,0,,10,0,,0,4.4,0,83.7,36.235142,49.967324,20170829112348,0255,0001,2760,9017,00,690.1,20170829112400,3456$")); |