aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-11-03 20:29:36 -0700
committerAnton Tananaev <anton@traccar.org>2022-11-03 20:29:36 -0700
commit9c03a0505f46a92f645dc927dba2da6458facfb1 (patch)
treeabd2af42f986c5c47cbebdecb5259f4f7b663fba /src/main
parent9280355123ee13f7f7d8bf7076a39dcab57ab1cd (diff)
downloadtrackermap-server-9c03a0505f46a92f645dc927dba2da6458facfb1.tar.gz
trackermap-server-9c03a0505f46a92f645dc927dba2da6458facfb1.tar.bz2
trackermap-server-9c03a0505f46a92f645dc927dba2da6458facfb1.zip
Reuse checksum code
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
index 8a58ebc5e..8e5269ec8 100644
--- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -363,17 +363,13 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
positions.add(position);
}
- if (channel != null) {
+ if (channel == null) {
StringBuilder command = new StringBuilder("@@");
command.append(flag).append(27 + positions.size() / 10).append(",");
command.append(imei).append(",CCC,").append(positions.size()).append("*");
- int checksum = 0;
- for (int i = 0; i < command.length(); i += 1) {
- checksum += command.charAt(i);
- }
- command.append(String.format("%02x", checksum & 0xff).toUpperCase());
+ command.append(Checksum.sum(command.toString()));
command.append("\r\n");
- channel.writeAndFlush(new NetworkMessage(command.toString(), remoteAddress)); // delete processed data
+ channel.writeAndFlush(new NetworkMessage(command.toString(), remoteAddress));
}
return positions;