aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java6
-rw-r--r--swagger.json10
-rw-r--r--test/org/traccar/protocol/CalAmpProtocolDecoderTest.java3
3 files changed, 14 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 99edb9fb7..47d7bf483 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,7 +130,9 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
for (int i = 0; i < accCount; i++) {
- position.set("acc" + i, buf.readUnsignedInt());
+ if (buf.readableBytes() >= 4) {
+ position.set("acc" + i, buf.readUnsignedInt());
+ }
}
return position;
diff --git a/swagger.json b/swagger.json
index 8b4157917..8fdbbf867 100644
--- a/swagger.json
+++ b/swagger.json
@@ -556,19 +556,20 @@
{
"name": "deviceId",
"in": "query",
- "required": true,
+ "description": "deviceId is optional, but requires the from and to parameters when used",
+ "required": false,
"type": "integer"
},
{
"name": "from",
"in": "query",
- "required": true,
+ "required": false,
"type": "string"
},
{
"name": "to",
"in": "query",
- "required": true,
+ "required": false,
"type": "string"
}
],
@@ -1115,6 +1116,9 @@
"id": {
"type": "integer"
},
+ "deviceId": {
+ "type": "integer"
+ },
"protocol": {
"type": "string"
},
diff --git a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
index 238e6df3f..9ed4c4a43 100644
--- a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class CalAmpProtocolDecoderTest extends ProtocolTest {
CalAmpProtocolDecoder decoder = new CalAmpProtocolDecoder(new CalAmpProtocol());
verifyPosition(decoder, binary(
+ "8305454205067001010102008157a9bddc57a96aaa17cdb98fccc1a457000056ac00000000000007250000ff8f000e00082711570000000000ffff101b00003148000010680000000000000000000000050000000000000000000005b0000000000000289600000000000000000000069b00000000000008e400000000000000000000000000000003000000010000070f"));
+
+ verifyPosition(decoder, binary(
"83052132052924010101020001575c590300000000000000000000000000000000000000000000002c0000ff8f0000030801010000"));
verifyPosition(decoder, binary(