diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-17 11:35:06 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-17 12:02:15 +1200 |
commit | 3f5122cbaf1710ae8d6c1c7ca9cf6a647f9a3f94 (patch) | |
tree | 2aef0b6edff4364f73df38c911add84a2c8f0e94 /src/org | |
parent | 9f4e34dd799187b32226652fdea9868c4ef5ddb4 (diff) | |
download | trackermap-server-3f5122cbaf1710ae8d6c1c7ca9cf6a647f9a3f94.tar.gz trackermap-server-3f5122cbaf1710ae8d6c1c7ca9cf6a647f9a3f94.tar.bz2 trackermap-server-3f5122cbaf1710ae8d6c1c7ca9cf6a647f9a3f94.zip |
Fix H02 short message handling
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolDecoder.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index b9b979c7d..aa3d47650 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -377,14 +377,19 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { case "*": String sentence = buf.toString(StandardCharsets.US_ASCII); int typeStart = sentence.indexOf(',', sentence.indexOf(',') + 1) + 1; - String type = sentence.substring(typeStart, sentence.indexOf(',', typeStart)); - switch (type) { - case "NBR": - return decodeLbs(sentence, channel, remoteAddress); - case "LINK": - return decodeLink(sentence, channel, remoteAddress); - default: - return decodeText(sentence, channel, remoteAddress); + int typeEnd = sentence.indexOf(',', typeStart); + if (typeEnd > 0) { + String type = sentence.substring(typeStart, typeEnd); + switch (type) { + case "NBR": + return decodeLbs(sentence, channel, remoteAddress); + case "LINK": + return decodeLink(sentence, channel, remoteAddress); + default: + return decodeText(sentence, channel, remoteAddress); + } + } else { + return null; } case "$": return decodeBinary(buf, channel, remoteAddress); |