aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranton2920 <anton2920@gmail.com>2022-07-24 17:32:01 +0100
committeranton2920 <anton2920@gmail.com>2022-09-07 09:48:53 +0100
commit1359371f83393e4a6a5dcbc0df03ab1b33bebde5 (patch)
treee2a273a5ea93b2c5f762391e24d4e50da3e4ff7e
parent3ae99730940f0f108a0c655f0cb52c109ca57885 (diff)
downloadtrackermap-server-1359371f83393e4a6a5dcbc0df03ab1b33bebde5.tar.gz
trackermap-server-1359371f83393e4a6a5dcbc0df03ab1b33bebde5.tar.bz2
trackermap-server-1359371f83393e4a6a5dcbc0df03ab1b33bebde5.zip
Added high-level payload parsing
-rw-r--r--src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
index 244df6806..dca8b1329 100644
--- a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -30,6 +30,7 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -150,6 +151,33 @@ public class PiligrimProtocolDecoder extends BaseHttpProtocolDecoder {
}
return positions;
+ } else if (uri.startsWith("/push.do")) {
+ /* Getting payload */
+ ByteBuf content_stream = request.content();
+ byte[] payload_bytes = new byte[Integer.parseInt(request.headers().get("Content-Length"))];
+ content_stream.readBytes(payload_bytes);
+ String payload = new String(payload_bytes);
+
+ /* Payload structure:
+ * &phone&message
+ */
+ String[] payload_parts = payload.split("&");
+ System.out.println("Payload parts: " + Arrays.toString(payload_parts));
+ String phone_number = payload_parts[1].substring(12);
+ String message = payload_parts[2].substring(8);
+ System.out.println("Phone number: " + phone_number);
+ System.out.println("Message: " + message);
+
+ /* Supported message structure:
+ * GPS NMEA Command; GSM info; Unknown; Battery voltage?
+ */
+ if (message.startsWith("$GPRMC")) {
+ System.out.println("Supported message");
+ } else {
+ System.out.println("Unsupported message");
+ }
+
+ System.out.println("Finish");
}
return null;