aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/StartekProtocolDecoder.java32
1 files changed, 31 insertions, 1 deletions
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());