aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-06 11:09:07 +0300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-08-06 11:09:07 +0300
commitd5ee7543705d8424cd0d4eaa900a667ea5e21095 (patch)
tree89573cebe9eb1c510db8e34930593b9aa7d20064 /src
parent683dce7d6475810910e6cfb2cab61efda43d2f80 (diff)
downloadtraccar-server-d5ee7543705d8424cd0d4eaa900a667ea5e21095.tar.gz
traccar-server-d5ee7543705d8424cd0d4eaa900a667ea5e21095.tar.bz2
traccar-server-d5ee7543705d8424cd0d4eaa900a667ea5e21095.zip
Decode Teltonika parameters (fix #2171)
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index d982b07b3..00ab90ce0 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -67,6 +67,32 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
+ private void decodeParameter(Position position, int id, long value) {
+ switch (id) {
+ case 9:
+ position.set(Position.PREFIX_ADC + 1, value);
+ break;
+ case 66:
+ position.set(Position.KEY_POWER, value);
+ break;
+ case 68:
+ position.set(Position.KEY_BATTERY, value);
+ break;
+ case 85:
+ position.set(Position.KEY_RPM, value);
+ break;
+ case 182:
+ position.set(Position.KEY_HDOP, value);
+ break;
+ case 239:
+ position.set(Position.KEY_IGNITION, value == 1);
+ break;
+ default:
+ position.set(Position.PREFIX_IO + id, value);
+ break;
+ }
+ }
+
private void decodeLocation(Position position, ChannelBuffer buf, int codec) {
int globalMask = 0x0f;
@@ -153,12 +179,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 1)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- int id = buf.readUnsignedByte();
- if (id == 1) {
- position.set(Position.KEY_POWER, buf.readUnsignedByte());
- } else {
- position.set(Position.PREFIX_IO + id, buf.readUnsignedByte());
- }
+ decodeParameter(position, buf.readUnsignedByte(), buf.readUnsignedByte());
}
}
@@ -166,7 +187,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 2)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readUnsignedShort());
+ decodeParameter(position, buf.readUnsignedByte(), buf.readUnsignedShort());
}
}
@@ -174,7 +195,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 3)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readUnsignedInt());
+ decodeParameter(position, buf.readUnsignedByte(), buf.readUnsignedInt());
}
}
@@ -182,7 +203,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (codec == CODEC_FM4X00) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readLong());
+ decodeParameter(position, buf.readUnsignedByte(), buf.readLong());
}
}