diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-16 11:47:57 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-16 11:47:57 +1300 |
commit | 8e69216a16915b5d9ac968928bb01d895e6993dc (patch) | |
tree | 5db0f6c15391b386dbe28269ee55685b1a0b1dae | |
parent | bd00157391f3989b5cfb36fd780446424bb1d7af (diff) | |
download | trackermap-server-8e69216a16915b5d9ac968928bb01d895e6993dc.tar.gz trackermap-server-8e69216a16915b5d9ac968928bb01d895e6993dc.tar.bz2 trackermap-server-8e69216a16915b5d9ac968928bb01d895e6993dc.zip |
Support XRB 28 command responses
-rw-r--r-- | src/org/traccar/protocol/Xrb28ProtocolDecoder.java | 49 | ||||
-rw-r--r-- | test/org/traccar/protocol/Xrb28ProtocolDecoderTest.java | 2 |
2 files changed, 33 insertions, 18 deletions
diff --git a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java index eb72dcd1b..9c5bc741a 100644 --- a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java @@ -88,30 +88,45 @@ public class Xrb28ProtocolDecoder extends BaseProtocolDecoder { } } - Parser parser = new Parser(PATTERN, sentence); - if (!parser.matches()) { - return null; - } + if (type.matches("R0|L0|L1|S4|S5|S6|S7|V0|G0|K0|I0|M0")) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); - Position position = new Position(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); + getLastLocation(position, null); - DateBuilder dateBuilder = new DateBuilder() - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.set(Position.KEY_RESULT, sentence.substring(25, sentence.length() - 1)); - position.setValid(parser.next().equals("A")); - position.setLatitude(parser.nextCoordinate()); - position.setLongitude(parser.nextCoordinate()); + return position; + + } else { + + Parser parser = new Parser(PATTERN, sentence); + if (!parser.matches()) { + return null; + } - position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.set(Position.KEY_HDOP, parser.nextDouble()); + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); - dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setTime(dateBuilder.getDate()); + DateBuilder dateBuilder = new DateBuilder() + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setAltitude(parser.nextDouble()); + position.setValid(parser.next().equals("A")); + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); - return position; + position.set(Position.KEY_SATELLITES, parser.nextInt()); + position.set(Position.KEY_HDOP, parser.nextDouble()); + + dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setAltitude(parser.nextDouble()); + + return position; + + } } } diff --git a/test/org/traccar/protocol/Xrb28ProtocolDecoderTest.java b/test/org/traccar/protocol/Xrb28ProtocolDecoderTest.java index 0eea02de7..cef1f38f9 100644 --- a/test/org/traccar/protocol/Xrb28ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Xrb28ProtocolDecoderTest.java @@ -19,7 +19,7 @@ public class Xrb28ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, text( "*HBCR,OM,123456789123456,Q0,412,80#")); - verifyNull(decoder, text( + verifyAttributes(decoder, text( "*HBCR,OM,123456789123456,R0,0,55,1234,1497689816#")); verifyPosition(decoder, text( |