aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authoranton2920 <anton2920@gmail.com>2022-07-24 17:47:13 +0100
committeranton2920 <anton2920@gmail.com>2022-09-07 09:48:53 +0100
commit16197c4bec4da40372da7505c6b2093da6b743f5 (patch)
tree4e61040e64c80ee78106f7781ab7f9f84163a37d /src/main/java/org/traccar
parent1359371f83393e4a6a5dcbc0df03ab1b33bebde5 (diff)
downloadtrackermap-server-16197c4bec4da40372da7505c6b2093da6b743f5.tar.gz
trackermap-server-16197c4bec4da40372da7505c6b2093da6b743f5.tar.bz2
trackermap-server-16197c4bec4da40372da7505c6b2093da6b743f5.zip
Added high-level parsing of message field
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
index dca8b1329..29b6d9ef0 100644
--- a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -168,11 +168,28 @@ public class PiligrimProtocolDecoder extends BaseHttpProtocolDecoder {
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")) {
+ /* Supported message structure:
+ * GPS NMEA Command; GSM info; Unknown; Battery voltage?
+ * Example: $GPRMC,180752.000,A,5314.0857,N,03421.8173,E,0.00,104.74,220722,,,A,V* 29,05; GSM: 250-01 0b54-0519,1c30,3e96,3ebe,412e 25; S; Batt: 405,M
+ */
System.out.println("Supported message");
+
+ String[] message_parts = message.split(";");
+ System.out.println("Message parts: " + Arrays.toString(message_parts));
+
+ /* Parsing GPS */
+ String unprocessed_gps_command = message_parts[0];
+
+ /* Getting rid of checksum */
+ String gps_command = unprocessed_gps_command.replaceFirst("A,V[*].*", "");
+ System.out.println("GPS command: " + gps_command);
+
+ /* Parsing other fields */
+ /* String gsm_info = message_parts[1]; */
+ /* String unknown = message_parts[2]; */
+ String battery_info = message_parts[3].substring(7).substring(0, 3);
+ System.out.println("Battery: " + battery_info);
} else {
System.out.println("Unsupported message");
}