diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-23 15:36:42 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-23 15:36:42 -0800 |
commit | 05e44d8cf956f6a0d44497aa0b357036139425dd (patch) | |
tree | bbf7d754379c3fe240d86f525102709d94b6ecd9 /src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | |
parent | ca41538149dc6fd549f9c6f7565e3cfd71957d1e (diff) | |
download | trackermap-server-05e44d8cf956f6a0d44497aa0b357036139425dd.tar.gz trackermap-server-05e44d8cf956f6a0d44497aa0b357036139425dd.tar.bz2 trackermap-server-05e44d8cf956f6a0d44497aa0b357036139425dd.zip |
Use correct prefix for commands
Diffstat (limited to 'src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index 08d8252a3..601d127f1 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -38,6 +38,8 @@ import java.util.TimeZone; public class SuntechProtocolDecoder extends BaseProtocolDecoder { + private String prefix; + private int protocolType; private boolean hbm; private boolean includeAdc; @@ -48,6 +50,10 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { super(protocol); } + public String getPrefix() { + return prefix; + } + public void setProtocolType(int protocolType) { this.protocolType = protocolType; } @@ -626,15 +632,16 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } else { String[] values = buf.toString(StandardCharsets.US_ASCII).split(";"); + prefix = values[0]; - if (values[0].length() < 5) { + if (prefix.length() < 5) { return decodeUniversal(channel, remoteAddress, values); - } else if (values[0].startsWith("ST9")) { + } else if (prefix.startsWith("ST9")) { return decode9(channel, remoteAddress, values); - } else if (values[0].startsWith("ST4")) { + } else if (prefix.startsWith("ST4")) { return decode4(channel, remoteAddress, values); } else { - return decode2356(channel, remoteAddress, values[0].substring(0, 5), values); + return decode2356(channel, remoteAddress, prefix.substring(0, 5), values); } } } |