aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-30 22:57:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-30 22:57:53 +1300
commitf757f587aca7491d27f2f536cf402de8cbee1d1e (patch)
treef8338f018052c835c07d97e7db98f2f540faeeaf
parent30d5a99aab58f8db6f3096d073db9b68c4b93c9d (diff)
downloadtrackermap-server-f757f587aca7491d27f2f536cf402de8cbee1d1e.tar.gz
trackermap-server-f757f587aca7491d27f2f536cf402de8cbee1d1e.tar.bz2
trackermap-server-f757f587aca7491d27f2f536cf402de8cbee1d1e.zip
Fix CalAmp mini report (fix #1430)
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java11
-rw-r--r--test/org/traccar/protocol/CalAmpProtocolDecoderTest.java3
2 files changed, 11 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 4dfb93440..f1cf6ae6f 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -62,6 +62,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
}
+ @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg)
throws Exception {
@@ -191,9 +192,11 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_STATUS, buf.readUnsignedByte());
}
- // Event code and status
+ // Event code
if (type == MSG_EVENT_REPORT || type == MSG_MINI_EVENT_REPORT) {
- buf.readUnsignedByte();
+ if (type != MSG_MINI_EVENT_REPORT) {
+ buf.readUnsignedByte(); // event index
+ }
position.set(Event.KEY_EVENT, buf.readUnsignedByte());
}
@@ -202,7 +205,9 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
int accType = accCount >> 6;
accCount &= 0x3f;
- buf.readUnsignedByte(); // reserved
+ if (type != MSG_MINI_EVENT_REPORT) {
+ buf.readUnsignedByte(); // reserved
+ }
if (accType == 1) {
buf.readUnsignedInt(); // threshold
diff --git a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
index 49ec086ca..77202d7b7 100644
--- a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class CalAmpProtocolDecoderTest extends ProtocolDecoderTest {
public void testDecode() throws Exception {
CalAmpProtocolDecoder decoder = new CalAmpProtocolDecoder(new CalAmpProtocol());
+
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
+ "830543321494860101010a0080560b5a5e0eadd0291becf3c500f005090f1f3305000003010040c0a600000000000000008b12a102"))));
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"830543321494860101010a0c215608b6680ead5ada1bed88d300000049801f000500000300003cf33200000000000000008b0ce101"))));