aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-05-16 09:57:27 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-05-16 09:57:27 -0700
commitbac4f925cc7d00f4ba0225d8b3391b6b382a588e (patch)
tree9a04ef6ca10f6659fe278045b89fccdfff4910c6 /src
parent1ebea9d3765ac5658b0513f3f8a3934d5b0d50d3 (diff)
downloadtrackermap-server-bac4f925cc7d00f4ba0225d8b3391b6b382a588e.tar.gz
trackermap-server-bac4f925cc7d00f4ba0225d8b3391b6b382a588e.tar.bz2
trackermap-server-bac4f925cc7d00f4ba0225d8b3391b6b382a588e.zip
Decode Cellocator ADC and inputs
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/CellocatorProtocolDecoder.java13
-rw-r--r--src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java3
2 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/main/java/org/traccar/protocol/CellocatorProtocolDecoder.java
index aa13a0aa2..bc74b6576 100644
--- a/src/main/java/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -22,6 +22,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.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -122,7 +123,12 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
position.set("mode", buf.readUnsignedByte());
- position.set(Position.KEY_INPUT, buf.readUnsignedIntLE());
+
+ long input = buf.readUnsignedIntLE();
+ position.set(Position.KEY_DOOR, BitUtil.check(input, 3 * 8));
+ position.set(Position.KEY_IGNITION, BitUtil.check(input, 2 * 8 + 7));
+ position.set(Position.KEY_CHARGE, BitUtil.check(input, 7));
+ position.set(Position.KEY_INPUT, input);
if (alternative) {
buf.readUnsignedByte(); // input
@@ -130,7 +136,10 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShortLE());
} else {
buf.readUnsignedByte(); // operator
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedIntLE());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedByte());
+ position.set(Position.PREFIX_ADC + 2, buf.readUnsignedByte());
+ position.set(Position.PREFIX_ADC + 3, buf.readUnsignedByte());
+ position.set(Position.PREFIX_ADC + 4, buf.readUnsignedByte());
}
position.set(Position.KEY_ODOMETER, buf.readUnsignedMediumLE());
diff --git a/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java
index 523ad1d5c..dcc4b267d 100644
--- a/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class CellocatorProtocolDecoderTest extends ProtocolTest {
CellocatorProtocolDecoder decoder = new CellocatorProtocolDecoder(null);
verifyPosition(decoder, binary(
+ "4D43475000856308000004B2DE1F04009E00200100000000696CF7AB002F1A00000000000000325C000402069BFDE70857E22502F41C000036000000DF0B0932100B09DC0719"));
+
+ verifyPosition(decoder, binary(
"4d4347500bde66220048165400cb0000000000080600000124161400061300050402095501aaf8218787fcac390100010000070700013133150f07131905001e000100000293001e00697e6f24148240040000000083400400000000844004000000008540040000000086400400000000874004000000008840040000000089400400000000814004000000008c4004000000008d4004000000008e4004000000009140040000000090400400000000804004000000008a400400000000974004000000008b4004000000009d4004000000009b400400000000da"));
verifyPosition(decoder, binary(