aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-02-14 10:47:03 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-02-14 10:47:16 -0800
commit421b663d45a18fa95a4873840bfaa671cc1724a8 (patch)
tree483f92129d109d2e1e6dea58a88e3bd6282a5b44
parent52e16f65e1f4b3c3d56bda60f16860db235b0e5c (diff)
downloadtrackermap-server-421b663d45a18fa95a4873840bfaa671cc1724a8.tar.gz
trackermap-server-421b663d45a18fa95a4873840bfaa671cc1724a8.tar.bz2
trackermap-server-421b663d45a18fa95a4873840bfaa671cc1724a8.zip
Alternative device id
-rw-r--r--src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java9
-rw-r--r--src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java3
2 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java b/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
index b6d7f4e45..71e2fccd6 100644
--- a/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,9 +75,9 @@ public class FreematicsProtocolDecoder extends BaseProtocolDecoder {
}
private Object decodePosition(
- Channel channel, SocketAddress remoteAddress, String sentence) throws Exception {
+ Channel channel, SocketAddress remoteAddress, String sentence, String id) {
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
}
@@ -187,12 +187,13 @@ public class FreematicsProtocolDecoder extends BaseProtocolDecoder {
int endIndex = sentence.indexOf('*');
if (startIndex > 0 && endIndex > 0) {
+ String id = sentence.substring(0, startIndex);
sentence = sentence.substring(startIndex + 1, endIndex);
if (sentence.startsWith("EV")) {
return decodeEvent(channel, remoteAddress, sentence);
} else {
- return decodePosition(channel, remoteAddress, sentence);
+ return decodePosition(channel, remoteAddress, sentence, id);
}
}
diff --git a/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java
index a84c4e357..2729f7af7 100644
--- a/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class FreematicsProtocolDecoderTest extends ProtocolTest {
FreematicsProtocolDecoder decoder = new FreematicsProtocolDecoder(null);
+ verifyPositions(decoder, text(
+ "M0ZR4X0#0:204391,11:140221,10:8445000,A:49.215920,B:18.737755,C:410,D:0,E:208,24:1252,20:0;0;0,82:47*B5"));
+
verifyNull(decoder, text(
"1#EV=2,TS=1871902,ID=ESP32305C06C40A24*AC"));