diff options
Diffstat (limited to 'src/main/java/org')
5 files changed, 42 insertions, 6 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(); |