aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk103ProtocolDecoder.java
diff options
context:
space:
mode:
authorninioe <ninioe@gmail.com>2016-08-07 09:56:04 +0300
committerninioe <ninioe@gmail.com>2016-08-07 09:56:04 +0300
commitc1c5a5fd34402a4e9b0840a7b960c38371dd9748 (patch)
tree1c04413e2f2cc450c4be23ef459597b2b4e9f776 /src/org/traccar/protocol/Tk103ProtocolDecoder.java
parente26d81c7430d8668b3af1bbf15672f06a855d6d0 (diff)
parentdea7617218de2cbc7ebd930b4342aa35ffedcd8b (diff)
downloadtrackermap-server-c1c5a5fd34402a4e9b0840a7b960c38371dd9748.tar.gz
trackermap-server-c1c5a5fd34402a4e9b0840a7b960c38371dd9748.tar.bz2
trackermap-server-c1c5a5fd34402a4e9b0840a7b960c38371dd9748.zip
Merge remote-tracking branch 'refs/remotes/tananaev/master'
# Conflicts: # web/app/view/LoginController.js
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;
}