aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-24 22:51:12 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-24 22:51:12 -0700
commitfb78c6a42f7e947b818044461414ef2470fc22f6 (patch)
tree4d1ae26732237feae87e45d8ea91b22050410c55 /src/main/java/org/traccar/protocol
parentae09c5920d0a89c1243cea81abe300272994ff6b (diff)
downloadtraccar-server-fb78c6a42f7e947b818044461414ef2470fc22f6.tar.gz
traccar-server-fb78c6a42f7e947b818044461414ef2470fc22f6.tar.bz2
traccar-server-fb78c6a42f7e947b818044461414ef2470fc22f6.zip
Decode GPS Sky China alarms
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index 11053e3b1..325d2ebeb 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -47,10 +47,16 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.groupBegin()
.expression("(.{12})") // device id
.or()
- .expression("(.+),") // device id
+ .expression("([^,]+),") // device id
.groupEnd()
.expression("(.{4}),?") // command
+ .groupBegin()
.number("(d*)")
+ .or()
+ .text(",ALARM,")
+ .number("(d),") // alarm type
+ .number("d+,")
+ .groupEnd()
.number("(dd)(dd)(dd),?") // date (mmddyy if comma-delimited, otherwise yyddmm)
.expression("([AV]),?") // validity
.number(" *(d+)(dd.d+)") // latitude
@@ -146,6 +152,30 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
private void decodeType(Position position, String type, String data) {
switch (type) {
+ case "BQ81":
+ switch (Integer.parseInt(data)) {
+ case 0:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ case 1:
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
+ break;
+ case 2:
+ position.set(Position.KEY_ALARM, Position.ALARM_IDLE);
+ break;
+ case 3:
+ position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION);
+ break;
+ case 4:
+ position.set(Position.KEY_ALARM, Position.ALARM_BRAKING);
+ break;
+ case 5:
+ position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE);
+ break;
+ default:
+ break;
+ }
+ break;
case "BO01":
position.set(Position.KEY_ALARM, decodeAlarm(data.charAt(0) - '0'));
break;
@@ -393,7 +423,15 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- decodeType(position, parser.next(), parser.next());
+ String type = parser.next();
+ String data = null;
+ if (parser.hasNext()) {
+ data = parser.next();
+ }
+ if (parser.hasNext()) {
+ data = parser.next();
+ }
+ decodeType(position, type, data);
DateBuilder dateBuilder = new DateBuilder();
if (alternative) {