From dbcde8aee59ebaa488cf9730a0356817e282ee84 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 11 Sep 2020 23:20:37 -0700 Subject: Decode driver id value --- .../org/traccar/protocol/SuntechProtocolDecoder.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index fd4af847f..76e3e6ecc 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -687,6 +687,24 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { return position; } + private Position decodeTravelReport(Channel channel, SocketAddress remoteAddress, String[] values) { + int index = 1; + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, values[index++]); + if (deviceSession == null) { + return null; + } + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + position.set(Position.KEY_DRIVER_UNIQUE_ID, values[values.length - 1]); + + return position; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -704,6 +722,8 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { if (prefix.length() < 5) { return decodeUniversal(channel, remoteAddress, values); + } else if (prefix.endsWith("HTE")) { + return decodeTravelReport(channel, remoteAddress, values); } else if (prefix.startsWith("ST9")) { return decode9(channel, remoteAddress, values); } else if (prefix.startsWith("ST4")) { -- cgit v1.2.3