diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-02-09 17:28:52 +1000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-02-09 17:28:52 +1000 |
commit | 810d4f77a77a7a66f22d747ef849925848b758f9 (patch) | |
tree | aeac50e9d29486baab10d2570153e24f4d089900 /src/org/traccar | |
parent | 9365b2309cbbf6d94f1fb24e7cbd9552757d39f7 (diff) | |
download | trackermap-server-810d4f77a77a7a66f22d747ef849925848b758f9.tar.gz trackermap-server-810d4f77a77a7a66f22d747ef849925848b758f9.tar.bz2 trackermap-server-810d4f77a77a7a66f22d747ef849925848b758f9.zip |
Support GPS103 OBD messages (fix #1632)
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/model/Event.java | 1 | ||||
-rw-r--r-- | src/org/traccar/protocol/AtrackProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 49 |
4 files changed, 52 insertions, 2 deletions
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 6e3aa7f22..a9f6f9204 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -50,6 +50,7 @@ public abstract class Event extends Extensible { public static final String KEY_RPM = "rpm"; public static final String KEY_VIN = "vin"; public static final String KEY_APPROXIMATE = "approximate"; + public static final String KEY_THROTTLE = "throttle"; public static final String KEY_OBD_SPEED = "obd-speed"; public static final String KEY_OBD_ODOMETER = "obd-odometer"; diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 2f0d692e9..72a17eed2 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -131,7 +131,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // engine load break; case "TR": - buf.readUnsignedByte(); // throttle position + position.set(Event.KEY_THROTTLE, buf.readUnsignedByte()); break; case "ET": buf.readUnsignedShort(); // engine coolant temp diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index a2681e10d..e4bf43979 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -203,7 +203,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set("odb-connect", parser.next()); position.set("dtcs-number", parser.next()); position.set("dtcs-codes", parser.next()); - position.set("throttle-position", parser.next()); + position.set(Event.KEY_THROTTLE, parser.next()); position.set(Event.KEY_FUEL, parser.next()); position.set(Event.KEY_OBD_ODOMETER, parser.next()); diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 2c7397231..61a96695c 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; +import org.traccar.helper.PatternUtil; import org.traccar.model.Event; import org.traccar.model.Position; @@ -78,6 +79,27 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { .number("##,imei:(d+),A") .compile(); + private static final Pattern PATTERN_OBD = new PatternBuilder() + .text("imei:") + .number("(d+),") // imei + .expression("OBD,") // type + .number("(dd)(dd)(dd)") // date + .number("(dd)(dd)(dd),") // time + .number("(d+),") // odometer + .number("(d+.d+)?,") // fuel instant + .number("(?:d+.d+)?,") // fuel average + .number("(d+),") // speed + .number("d+,") // power load + .number("(d+.d+%),") // throttle + .number("(d+),") // rpm + .number("(d+.d+%),") // battery + .number("[^,]*,") // dtc 1 + .number("[^,]*,") // dtc 2 + .number("[^,]*,") // dtc 3 + .number("[^,]*") // dtc 4 + .any() + .compile(); + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -124,6 +146,33 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } + String x = PatternUtil.checkPattern(PATTERN_OBD.pattern(), sentence); + + parser = new Parser(PATTERN_OBD, sentence); + if (parser.matches()) { + + if (!identify(parser.next(), channel, remoteAddress)) { + return null; + } + position.setDeviceId(getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + + getLastLocation(position, dateBuilder.getDate()); + + position.set(Event.KEY_ODOMETER, parser.nextInt()); + position.set(Event.KEY_FUEL, parser.next()); + position.set(Event.KEY_OBD_SPEED, parser.next()); + position.set(Event.KEY_THROTTLE, parser.next()); + position.set(Event.KEY_RPM, parser.next()); + position.set(Event.KEY_BATTERY, parser.next()); + + return position; + + } + parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; |