aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-08-08 11:37:02 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-08-08 11:37:02 -0700
commit23c38ed4e661c89c6dfa2f0139efa7620c6fb429 (patch)
tree355ea9dc668a06403a3af96da4c67c5b87d58265
parentc686cfff8bbecd351ddc9c44724fafc3ac987dc2 (diff)
downloadtrackermap-server-23c38ed4e661c89c6dfa2f0139efa7620c6fb429.tar.gz
trackermap-server-23c38ed4e661c89c6dfa2f0139efa7620c6fb429.tar.bz2
trackermap-server-23c38ed4e661c89c6dfa2f0139efa7620c6fb429.zip
Decode missing attributes
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java45
-rw-r--r--src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java5
2 files changed, 31 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index 451b9ba32..fd4af847f 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -479,20 +479,21 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateFormat.parse(values[index++] + values[index++]));
}
+ CellTower cellTower = new CellTower();
if (BitUtil.check(mask, 6)) {
- index += 1; // cell
+ cellTower.setCellId(Long.parseLong(values[index++], 16));
}
-
if (BitUtil.check(mask, 7)) {
- index += 1; // mcc
+ cellTower.setMobileCountryCode(Integer.parseInt(values[index++]));
}
-
if (BitUtil.check(mask, 8)) {
- index += 1; // mnc
+ cellTower.setMobileNetworkCode(Integer.parseInt(values[index++]));
}
-
if (BitUtil.check(mask, 9)) {
- index += 1; // lac
+ cellTower.setLocationAreaCode(Integer.parseInt(values[index++], 16));
+ }
+ if (cellTower.getCellId() != null) {
+ position.setNetwork(new Network(cellTower));
}
if (BitUtil.check(mask, 10)) {
@@ -531,16 +532,26 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_OUTPUT, Integer.parseInt(values[index++]));
}
- if (BitUtil.check(mask, 19)) {
- position.set("alertId", values[index++]);
- }
-
- if (BitUtil.check(mask, 20)) {
- position.set("alertModifier", values[index++]);
- }
-
- if (BitUtil.check(mask, 21)) {
- position.set("alertData", values[index++]);
+ if (type.equals("ALT")) {
+ if (BitUtil.check(mask, 19)) {
+ position.set("alertId", values[index++]);
+ }
+ if (BitUtil.check(mask, 20)) {
+ position.set("alertModifier", values[index++]);
+ }
+ if (BitUtil.check(mask, 21)) {
+ position.set("alertData", values[index++]);
+ }
+ } else {
+ if (BitUtil.check(mask, 19)) {
+ position.set("mode", Integer.parseInt(values[index++]));
+ }
+ if (BitUtil.check(mask, 20)) {
+ position.set("reason", Integer.parseInt(values[index++]));
+ }
+ if (BitUtil.check(mask, 21)) {
+ position.set(Position.KEY_INDEX, Integer.parseInt(values[index++]));
+ }
}
if (BitUtil.check(mask, 22)) {
diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
index 549402697..265eae334 100644
--- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -67,8 +67,9 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null);
- verifyPosition(decoder, buffer(
- "ALT;0470001109;BFFFFF;47;1.0.2;0;20200511;22:39:38;0B29790F;310;410;2C13;30;+34.928093;-83.704295;0.94;30.95;10;1;00000001;00000000;15;;;00018003;4.1;14.13;629;11905"));
+ verifyAttribute(decoder, buffer(
+ "STT;0560001616;BFFFFF;56;1.0.15;1;20200219;20:52:25;00008D6C;334;20;0925;24;+20.741764;-103.430364;0.00;0.00;19;1;00000001;00000000;2;1;1765;00008003;0.0;12.14;136598"),
+ Position.KEY_INDEX, 1765);
verifyAttribute(decoder, buffer(
"STT;0560001616;BFFFFF;56;1.0.15;1;20200219;20:52:25;00008D6C;334;20;0925;24;+20.741764;-103.430364;0.00;0.00;19;1;00000001;00000000;2;1;1765;00008003;0.0;12.14;136598"),