diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-04 14:22:08 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-04 14:22:08 -0700 |
commit | aeac485a8fea8012dab2465b0a6aa43137de1b57 (patch) | |
tree | 892e652855498c8b3a893de057864769f04619dc /src/main/java | |
parent | 3763481d2383ccd442979c7f7e656ef76c62ae95 (diff) | |
download | trackermap-server-aeac485a8fea8012dab2465b0a6aa43137de1b57.tar.gz trackermap-server-aeac485a8fea8012dab2465b0a6aa43137de1b57.tar.bz2 trackermap-server-aeac485a8fea8012dab2465b0a6aa43137de1b57.zip |
Respond to other message types
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/RstProtocolDecoder.java | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java index b45fdbb5a..9e3261a04 100644 --- a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java @@ -43,6 +43,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { .number("(d{9});") // serial number .number("(d+);") // index .number("(d+);") // type + .groupBegin() .number("(dd)-(dd)-(dddd) ") // event date .number("(dd):(dd):(dd);") // event time .number("(dd)-(dd)-(dddd) ") // fix date @@ -68,6 +69,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { .number("x{4};") // sensors .number("(xx);") // status 1 .number("(xx);") // status 2 + .groupEnd("?") .any() .compile(); @@ -85,7 +87,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { String firmware = parser.next(); String serial = parser.next(); int index = parser.nextInt(); - parser.nextInt(); // type + int type = parser.nextInt(); if (channel != null) { String response = "RST;A;" + model + ";" + firmware + ";" + serial + ";" + index + ";6;FIM;"; @@ -97,36 +99,44 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { return null; } - Position position = new Position(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - - position.setDeviceTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); - position.setFixTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); - position.setLatitude(parser.nextDouble()); - position.setLongitude(parser.nextDouble()); - position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt())); - position.setCourse(parser.nextInt()); - position.setAltitude(parser.nextInt()); - position.setValid(parser.nextInt() > 0); - - position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.set(Position.KEY_HDOP, parser.nextInt()); - position.set(Position.PREFIX_IN + 1, parser.nextHexInt()); - position.set(Position.PREFIX_IN + 2, parser.nextHexInt()); - position.set(Position.PREFIX_IN + 3, parser.nextHexInt()); - position.set(Position.PREFIX_OUT + 1, parser.nextHexInt()); - position.set(Position.PREFIX_OUT + 2, parser.nextHexInt()); - position.set(Position.KEY_POWER, parser.nextDouble()); - position.set(Position.KEY_BATTERY, parser.nextDouble()); - position.set(Position.KEY_ODOMETER, parser.nextInt()); - position.set(Position.KEY_RSSI, parser.nextInt()); - position.set(Position.PREFIX_TEMP + 1, (int) parser.nextHexInt().byteValue()); - - int status = (parser.nextHexInt() << 8) + parser.nextHexInt(); - position.set(Position.KEY_IGNITION, BitUtil.check(status, 7)); - position.set(Position.KEY_STATUS, status); - - return position; + if (parser.hasNext()) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + position.setDeviceTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); + position.setFixTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); + position.setLatitude(parser.nextDouble()); + position.setLongitude(parser.nextDouble()); + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt())); + position.setCourse(parser.nextInt()); + position.setAltitude(parser.nextInt()); + position.setValid(parser.nextInt() > 0); + + position.set(Position.KEY_SATELLITES, parser.nextInt()); + position.set(Position.KEY_HDOP, parser.nextInt()); + position.set(Position.PREFIX_IN + 1, parser.nextHexInt()); + position.set(Position.PREFIX_IN + 2, parser.nextHexInt()); + position.set(Position.PREFIX_IN + 3, parser.nextHexInt()); + position.set(Position.PREFIX_OUT + 1, parser.nextHexInt()); + position.set(Position.PREFIX_OUT + 2, parser.nextHexInt()); + position.set(Position.KEY_POWER, parser.nextDouble()); + position.set(Position.KEY_BATTERY, parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.nextInt()); + position.set(Position.KEY_RSSI, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 1, (int) parser.nextHexInt().byteValue()); + + int status = (parser.nextHexInt() << 8) + parser.nextHexInt(); + position.set(Position.KEY_IGNITION, BitUtil.check(status, 7)); + position.set(Position.KEY_STATUS, status); + + return position; + + } else { + + return null; + + } } } |