aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/config/Keys.java4
-rw-r--r--src/main/java/org/traccar/protocol/KhdProtocolDecoder.java8
-rw-r--r--src/main/java/org/traccar/protocol/StartekProtocolDecoder.java32
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java2
-rw-r--r--src/main/java/org/traccar/web/WebServer.java2
-rw-r--r--src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java4
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java3
-rw-r--r--swagger.json2
8 files changed, 50 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index c542b7099..ef0edbac3 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1201,8 +1201,8 @@ public final class Keys {
/**
* Enables persisting Jetty session to the database
*/
- public static final ConfigKey<Boolean> WEB_SESSION_PERSISTED = new ConfigKey<>(
- "web.sessionPersisted",
+ public static final ConfigKey<Boolean> WEB_PERSIST_SESSION = new ConfigKey<>(
+ "web.persistSession",
Collections.singletonList(KeyType.GLOBAL));
/**
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
index 251351a74..371b0f71c 100644
--- a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
@@ -162,7 +162,13 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
if (type != MSG_ALARM) {
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ int odometer = buf.readUnsignedMedium();
+ if (BitUtil.to(odometer, 16) > 0) {
+ position.set(Position.KEY_ODOMETER, odometer);
+ } else if (odometer > 0) {
+ position.set(Position.KEY_FUEL_LEVEL, BitUtil.from(odometer, 16));
+ }
+
position.set(Position.KEY_STATUS, buf.readUnsignedInt());
buf.readUnsignedShort();
diff --git a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
index 68fc511aa..aae764993 100644
--- a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
@@ -41,6 +41,11 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
.expression(".") // index
.number("d+,") // length
.number("(d+),") // imei
+ .expression("(.+)") // content
+ .number("xx") // checksum
+ .compile();
+
+ private static final Pattern PATTERN_POSITION = new PatternBuilder()
.number("xxx,") // command
.number("(d+),") // event
.expression("([^,]+)?,") // event data
@@ -75,7 +80,6 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
.expression("([^,]+)?") // temperature
.groupEnd("?")
.groupEnd("?")
- .number("xx") // checksum
.compile();
private String decodeAlarm(int value) {
@@ -108,6 +112,32 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ String content = parser.next();
+ if (content.length() < 100) {
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_RESULT, content);
+
+ return position;
+
+ } else {
+
+ return decodePosition(deviceSession, content);
+
+ }
+ }
+
+ protected Object decodePosition(DeviceSession deviceSession, String content) throws Exception {
+
+ Parser parser = new Parser(PATTERN_POSITION, content);
+ if (!parser.matches()) {
+ return null;
+ }
+
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index 5ff0bbb6c..564acd7b4 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -101,7 +101,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
return Position.ALARM_GEOFENCE_ENTER;
} else if (BitUtil.check(status, 20)) {
return Position.ALARM_REMOVING;
- } else if (BitUtil.check(status, 21)) {
+ } else if (BitUtil.check(status, 21) || BitUtil.check(status, 22)) {
return Position.ALARM_FALL_DOWN;
}
return null;
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index 0157c075c..604edfedc 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -178,7 +178,7 @@ public class WebServer {
}
private void initSessionConfig(Config config, ServletContextHandler servletHandler) {
- if (config.getBoolean(Keys.WEB_SESSION_PERSISTED)) {
+ if (config.getBoolean(Keys.WEB_PERSIST_SESSION)) {
DatabaseAdaptor databaseAdaptor = new DatabaseAdaptor();
databaseAdaptor.setDatasource(Context.getDataManager().getDataSource());
JDBCSessionDataStoreFactory jdbcSessionDataStoreFactory = new JDBCSessionDataStoreFactory();
diff --git a/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java
index 81f2f8f69..e85672326 100644
--- a/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java
@@ -11,6 +11,10 @@ public class StartekProtocolDecoderTest extends ProtocolTest {
var decoder = new StartekProtocolDecoder(null);
+ verifyAttribute(decoder, text(
+ "&&:23,860262050015424,129,OKA2"),
+ Position.KEY_RESULT, "129,OK");
+
verifyPosition(decoder, text(
"&&o125,861157040554384,000,0,,210702235150,A,27.263505,153.037061,11,1.2,0,0,31,5125,505|1|7032|8C89802,20,0000002D,00,00,01E2|019DF0"));
diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
index ddfc8e619..73b97d1b4 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -16,6 +16,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
var decoder = new WatchProtocolDecoder(null);
verifyPosition(decoder, buffer(
+ "[3G*2104326058*00E9*UD_LTE,300621,135101,A,32.162652,N,34.888748,E,30.84,265.158,65.621,18,100,83,0,0,00000000,1,1,425,01,10223,8012811,100,3,ES4104,22:74:1d:39:64:ff,-46,metropoline-wifi,a8:3f:a1:e0:66:ba,-89,Egged.co.il,00:0c:42:51:cf:cd,-81,1.7055488]"));
+
+ verifyPosition(decoder, buffer(
"[3G*358839237678820*0122*ALCUSTOMER1,251120,081821,V,0.0,N,0.0,E,2.58,317.462,35.147,14,100,2,11089,0,00100008,1,1,460,01,42308,101992452,100,5,shizhou1,44:56:e2:03:ea:2a,-69,FART3,30:0d:9e:bb:fa:4d,-70,ZKY-A209,88:c3:97:c1:f4:7f,-73,ChinaNet-HNeD,e8:84:c6:21:7c:dc,-77,,30:45:96:10:14:5d,-79,1.2035439]"));
verifyPosition(decoder, buffer(
diff --git a/swagger.json b/swagger.json
index 5fb20bfdb..ccb588a50 100644
--- a/swagger.json
+++ b/swagger.json
@@ -2989,7 +2989,7 @@
"type": {
"type": "string"
},
- "serverTime": {
+ "eventTime": {
"type": "string",
"description": "in IS0 8601 format. eg. `1963-11-22T18:30:00Z`",
"format": "date-time"