aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TeltonikaProtocolDecoder.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/TeltonikaProtocolDecoder.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/TeltonikaProtocolDecoder.java')
-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());
}
}