aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-11 12:27:04 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-11 12:27:04 -0700
commit1d3cd09b327535388d78297c0f6a249a66331cea (patch)
tree83e42eae89d0d5763e33264eb57618837afaedd3 /src/main/java/org/traccar
parentc915753bb9490796f3ce27c7b07d50370fdf67e5 (diff)
downloadtrackermap-server-1d3cd09b327535388d78297c0f6a249a66331cea.tar.gz
trackermap-server-1d3cd09b327535388d78297c0f6a249a66331cea.tar.bz2
trackermap-server-1d3cd09b327535388d78297c0f6a249a66331cea.zip
Support iStartek command results
Diffstat (limited to 'src/main/java/org/traccar')
-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());