aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-27 19:28:31 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-27 19:28:31 -0700
commitbb50a4178d171d40734b94fccf52b72733f1f04c (patch)
treebc49709d4b6c9275928ebe4b422e42b2eeacc7d0 /src
parent950a35723b8ad3e9383c55d8b84812d012da3085 (diff)
downloadtrackermap-server-bb50a4178d171d40734b94fccf52b72733f1f04c.tar.gz
trackermap-server-bb50a4178d171d40734b94fccf52b72733f1f04c.tar.bz2
trackermap-server-bb50a4178d171d40734b94fccf52b72733f1f04c.zip
Watch zero cell towers
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java24
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java3
2 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index 4ab7875b7..b25a15f93 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -145,17 +145,19 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
int cellCount = Integer.parseInt(values[index++]);
index += 1; // timing advance
- int mcc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
- int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
-
- for (int i = 0; i < cellCount; i++) {
- int lac = Integer.parseInt(values[index++]);
- int cid = Integer.parseInt(values[index++]);
- String rssi = values[index++];
- if (!rssi.isEmpty()) {
- network.addCellTower(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(rssi)));
- } else {
- network.addCellTower(CellTower.from(mcc, mnc, lac, cid));
+ if (cellCount > 0) {
+ int mcc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
+ int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
+
+ for (int i = 0; i < cellCount; i++) {
+ int lac = Integer.parseInt(values[index++]);
+ int cid = Integer.parseInt(values[index++]);
+ String rssi = values[index++];
+ if (!rssi.isEmpty()) {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(rssi)));
+ } else {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid));
+ }
}
}
diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
index 4fab19f26..34ef7839b 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -15,6 +15,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
var decoder = new WatchProtocolDecoder(null);
+ verifyPosition(decoder, buffer(
+ "[3G*9031853319*004E*UD2,220322,055105,A,22.761162,N,114.360192,E,0,0,47,14,100,64,0,0,00000008,0,0]"));
+
verifyAttribute(decoder, buffer(
"[3G*2104326058*000E*btemp2,1,35.29]"),
Position.PREFIX_TEMP + 1, 35.29);