aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-11 20:00:01 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-09-11 20:00:01 +1200
commit8aa35f1e9d3a32f7935415d1d910b4bc19f53df0 (patch)
treebfd6bf23d2da520106027c01035523bf9f75455c /src/org
parent3426e6fb00c64540a846b8b1e4d5e626ae791fd7 (diff)
downloadtraccar-server-8aa35f1e9d3a32f7935415d1d910b4bc19f53df0.tar.gz
traccar-server-8aa35f1e9d3a32f7935415d1d910b4bc19f53df0.tar.bz2
traccar-server-8aa35f1e9d3a32f7935415d1d910b4bc19f53df0.zip
Minor ADM protocol cleanup
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/AdmProtocolDecoder.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java
index 80c580967..f93c55e18 100644
--- a/src/org/traccar/protocol/AdmProtocolDecoder.java
+++ b/src/org/traccar/protocol/AdmProtocolDecoder.java
@@ -39,6 +39,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ADM5 = 0x01;
private Position decodeData(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int type) {
+
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
return null;
@@ -71,32 +72,34 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
if (BitUtil.check(type, 2)) {
- buf.skipBytes(2); // vib, vib_count
+ buf.readUnsignedByte(); // vib
+ buf.readUnsignedByte(); // vib_count
int out = buf.readUnsignedByte();
- for (int i = 0; i <= 3; ++i) {
+ for (int i = 0; i <= 3; i++) {
position.set(Position.PREFIX_OUT + (i + 1), BitUtil.check(out, i) ? 1 : 0);
}
- buf.skipBytes(1); // in_alarm
+ buf.readUnsignedByte(); // in_alarm
}
if (BitUtil.check(type, 3)) {
- for (int i = 1; i <= 6; ++i) {
+ for (int i = 1; i <= 6; i++) {
position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort() * 0.001);
}
}
if (BitUtil.check(type, 4)) {
- for (int i = 1; i <= 2; ++i) {
+ for (int i = 1; i <= 2; i++) {
position.set(Position.PREFIX_COUNT + i, buf.readUnsignedInt());
}
}
if (BitUtil.check(type, 5)) {
- buf.skipBytes(6); // fuel level 0..2
-
- for (int i = 1; i <= 3; ++i) {
+ for (int i = 1; i <= 3; i++) {
+ buf.readUnsignedShort(); // fuel level
+ }
+ for (int i = 1; i <= 3; i++) {
position.set(Position.PREFIX_TEMP + i, buf.readUnsignedByte());
}
}
@@ -156,4 +159,5 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+
}