aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/CalAmpProtocolDecoder.java42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/main/java/org/traccar/protocol/CalAmpProtocolDecoder.java
index dad0ae774..59b1fdf21 100644
--- a/src/main/java/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
+import java.nio.charset.StandardCharsets;
import java.util.Date;
public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
@@ -121,22 +122,34 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
}
- int accType = BitUtil.from(buf.getUnsignedByte(buf.readerIndex()), 6);
- int accCount = BitUtil.to(buf.readUnsignedByte(), 6);
+ if (type == MSG_EVENT_REPORT || type == MSG_LOCATE_REPORT || type == MSG_MINI_EVENT_REPORT) {
- if (type != MSG_MINI_EVENT_REPORT) {
- position.set("append", buf.readUnsignedByte());
- }
+ int accType = BitUtil.from(buf.getUnsignedByte(buf.readerIndex()), 6);
+ int accCount = BitUtil.to(buf.readUnsignedByte(), 6);
- if (accType == 1) {
- buf.readUnsignedInt(); // threshold
- buf.readUnsignedInt(); // mask
- }
+ if (type != MSG_MINI_EVENT_REPORT) {
+ position.set("append", buf.readUnsignedByte());
+ }
- for (int i = 0; i < accCount; i++) {
- if (buf.readableBytes() >= 4) {
- position.set("acc" + i, buf.readUnsignedInt());
+ if (accType == 1) {
+ buf.readUnsignedInt(); // threshold
+ buf.readUnsignedInt(); // mask
}
+
+ for (int i = 0; i < accCount; i++) {
+ if (buf.readableBytes() >= 4) {
+ position.set("acc" + i, buf.readUnsignedInt());
+ }
+ }
+
+ } else if (type == MSG_USER_DATA) {
+
+ buf.readUnsignedByte(); // message route
+ buf.readUnsignedByte(); // message id
+ position.set(
+ Position.KEY_RESULT,
+ buf.readCharSequence(buf.readUnsignedShort(), StandardCharsets.US_ASCII).toString().trim());
+
}
return position;
@@ -192,7 +205,8 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, remoteAddress, type, index, 0);
}
- if (type == MSG_EVENT_REPORT || type == MSG_LOCATE_REPORT || type == MSG_MINI_EVENT_REPORT) {
+ if (type == MSG_EVENT_REPORT || type == MSG_LOCATE_REPORT
+ || type == MSG_MINI_EVENT_REPORT || type == MSG_USER_DATA) {
return decodePosition(deviceSession, type, buf);
}