aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-11-30 17:22:16 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-11-30 17:22:16 -0800
commit27509dcce40dd8528c5bd54954bd4e13612a14ef (patch)
treeee8e619872d5f16a0252b72fcec609f139f8c0a3 /src/main/java/org/traccar/protocol
parent511520f9ac393735ec2c9fc5a18b2d4be8d071c5 (diff)
downloadtrackermap-server-27509dcce40dd8528c5bd54954bd4e13612a14ef.tar.gz
trackermap-server-27509dcce40dd8528c5bd54954bd4e13612a14ef.tar.bz2
trackermap-server-27509dcce40dd8528c5bd54954bd4e13612a14ef.zip
Decode state attributes
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/CastelProtocolDecoder.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java b/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
index 03e4b25fd..53a66af27 100644
--- a/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.ObdDecoder;
@@ -185,7 +186,14 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedIntLE());
position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedIntLE());
buf.readUnsignedShortLE(); // current fuel consumption
- position.set(Position.KEY_STATUS, buf.readUnsignedIntLE());
+
+ long state = buf.readUnsignedIntLE();
+ position.set(Position.KEY_IGNITION, BitUtil.check(state, 8 + 2));
+ position.set(Position.KEY_ALARM, BitUtil.check(state, 3 * 8 + 4) ? Position.ALARM_ACCELERATION : null);
+ position.set(Position.KEY_ALARM, BitUtil.check(state, 3 * 8 + 5) ? Position.ALARM_BRAKING : null);
+ position.set(Position.KEY_ALARM, BitUtil.check(state, 3 * 8 + 6) ? Position.ALARM_IDLE : null);
+ position.set(Position.KEY_STATUS, state);
+
buf.skipBytes(8);
}