aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk103ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/Tk103ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index a76c208b5..ac99a1440 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,6 +51,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.number("(?:([01]{8})|(x{8}))?,?") // state
.number("(?:L(x+))?") // odometer
.any()
+ .number("([+-]ddd.d)?") // temperature
.text(")").optional()
.compile();
@@ -75,6 +76,25 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 1:
+ return Position.ALARM_ACCIDENT;
+ case 2:
+ return Position.ALARM_SOS;
+ case 3:
+ return Position.ALARM_VIBRATION;
+ case 4:
+ return Position.ALARM_LOW_SPEED;
+ case 5:
+ return Position.ALARM_OVERSPEED;
+ case 6:
+ return Position.ALARM_GEOFENCE_EXIT;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -160,7 +180,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
int alarm = sentence.indexOf("BO01");
if (alarm != -1) {
- position.set(Position.KEY_ALARM, Integer.parseInt(sentence.substring(alarm + 4, alarm + 5)));
+ position.set(Position.KEY_ALARM, decodeAlarm(Integer.parseInt(sentence.substring(alarm + 4, alarm + 5))));
}
DateBuilder dateBuilder = new DateBuilder();
@@ -206,6 +226,10 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.nextLong(16));
}
+ if (parser.hasNext()) {
+ position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
+ }
+
return position;
}