diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-28 16:36:06 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-28 16:36:06 -0700 |
commit | 6c1ba89c82c0a07e6a33e4ea437953fbfc4dc1bd (patch) | |
tree | 1e0ff34ac61b1d3d05c3e3d109a24149493c499f /src/main/java/org/traccar/protocol | |
parent | 21bd340006570f24cad6100e2346e09977879147 (diff) | |
download | traccar-server-6c1ba89c82c0a07e6a33e4ea437953fbfc4dc1bd.tar.gz traccar-server-6c1ba89c82c0a07e6a33e4ea437953fbfc4dc1bd.tar.bz2 traccar-server-6c1ba89c82c0a07e6a33e4ea437953fbfc4dc1bd.zip |
Decode TK103 VIN number
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java index 325d2ebeb..1a45fbf75 100644 --- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -131,6 +131,14 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private static final Pattern PATTERN_VIN = new PatternBuilder() + .text("(") + .number("(d+)") // device id + .expression("BV00") // command + .expression("(.{17})") // vin + .text(")") + .compile(); + private String decodeAlarm(int value) { switch (value) { case 1: @@ -370,7 +378,27 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RESULT, parser.next()); return position; + } + + private Position decodeVin(Channel channel, SocketAddress remoteAddress, String sentence) { + Parser parser = new Parser(PATTERN_VIN, sentence); + if (!parser.matches()) { + return null; + } + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + position.set(Position.KEY_VIN, parser.next()); + + return position; } @Override @@ -398,6 +426,8 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { return decodeCommandResult(channel, remoteAddress, sentence); } else if (sentence.contains("DW5")) { return decodeLbsWifi(channel, remoteAddress, sentence); + } else if (sentence.contains("BV00")) { + return decodeVin(channel, remoteAddress, sentence); } Parser parser = new Parser(PATTERN, sentence); |