aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:28:27 +0300
committerVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:28:27 +0300
commitbb211eea5f62014c0700138e922cb1adcdc9d9dd (patch)
tree418b6a3b5fb006936d549e8e1a831d09b1544ae3 /src/org/traccar/protocol
parent2d145a029bf45d309366b5b6367befd00efb5efc (diff)
downloadtrackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.tar.gz
trackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.tar.bz2
trackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.zip
Support old protocol versions without checksum
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 287235fb1..6d066299a 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -219,7 +219,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // lac
.number("(d+),") // gsm signal
.number("(d+),") // odometer
- .number("(d+),") // serial number
+ .number("(d+),?") // serial number
.number("(xx)").optional() // checksum
.any()
.compile();
@@ -267,13 +267,19 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
case "U01":
case "U02":
case "U03":
- int checkSum = parser.nextInt(16);
- int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3));
- if (checkSum == calculatedCheckSum) {
- sendResponse(channel, "(S39)");
- return position;
+ // support protocol with check sum
+ if (parser.hasNext(2)) {
+ int checkSum = parser.nextInt(16);
+ int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3));
+ if (checkSum == calculatedCheckSum) {
+ sendResponse(channel, "(S39)");
+ return position;
+ } else {
+ return null;
+ }
+ // support protocol without check sum
} else {
- return null;
+ return position;
}
case "U06":
sendResponse(channel, "(S20)");