aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-04-13 20:24:53 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-04-13 20:24:53 -0700
commit90c2f67629064126834450aafcaffdc4187fe55a (patch)
tree8f574a40fa974e19473baaaa9042bd6f646fae2e /src/main/java
parent57b5aa9ada42f1c113dc0cef8f259b55b6f9ea69 (diff)
downloadtrackermap-server-90c2f67629064126834450aafcaffdc4187fe55a.tar.gz
trackermap-server-90c2f67629064126834450aafcaffdc4187fe55a.tar.bz2
trackermap-server-90c2f67629064126834450aafcaffdc4187fe55a.zip
Support Mictrack command results
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
index 5ea9f148c..029e7d99c 100644
--- a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2021 Anton Tananaev (anton@traccar.org)
* Copyright 2020 Roeland Boeters (roeland@geodelta.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -168,8 +168,48 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("MT")) {
return decodeStandard(channel, remoteAddress, sentence);
- } else {
+ } else if (sentence.contains("$")) {
return decodeLowAltitude(channel, remoteAddress, sentence);
+ } else {
+ return decodeResult(channel, remoteAddress, sentence);
+ }
+ }
+
+ private Object decodeResult(
+ Channel channel, SocketAddress remoteAddress, String sentence) throws Exception {
+
+ if (sentence.matches("\\d{15} .+")) {
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, sentence.substring(0, 15));
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_RESULT, sentence.substring(16, sentence.length() - 1));
+
+ return position;
+
+ } else {
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_RESULT, sentence.substring(0, sentence.length() - 1));
+
+ return position;
+
}
}