aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/H02ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-20 08:42:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-20 08:42:20 +1300
commit13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a (patch)
treea7d3450db8ccb6698ed4e7794f27ceaf939807c9 /src/org/traccar/protocol/H02ProtocolDecoder.java
parent301b44775fb4ed66fae5c801da3c52f7b88b9697 (diff)
downloadtrackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.tar.gz
trackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.tar.bz2
trackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.zip
Refactor protocols for network location
Diffstat (limited to 'src/org/traccar/protocol/H02ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 2c7852d16..431dd5c3c 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -25,6 +25,8 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -249,10 +251,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
int lac = parser.nextInt(16);
int cid = parser.nextInt(16);
if (mcc != 0 && mnc != 0 && lac != 0 && cid != 0) {
- position.set(Position.KEY_MCC, mcc);
- position.set(Position.KEY_MNC, mnc);
- position.set(Position.KEY_LAC, lac);
- position.set(Position.KEY_CID, cid);
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, lac, cid)));
}
}
@@ -278,13 +277,17 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
+ Network network = new Network();
+ int mcc = parser.nextInt();
+ int mnc = parser.nextInt();
- String[] cells = parser.next().split(","); // decode all in future
- position.set(Position.KEY_LAC, Integer.parseInt(cells[0]));
- position.set(Position.KEY_CID, Integer.parseInt(cells[1]));
- position.set(Position.KEY_GSM, Integer.parseInt(cells[2]));
+ String[] cells = parser.next().split(",");
+ for (int i = 0; i < cells.length / 3; i++) {
+ network.addCellTower(CellTower.from(mcc, mnc, Integer.parseInt(cells[i * 3]),
+ Integer.parseInt(cells[i * 3 + 1]), Integer.parseInt(cells[i * 3 + 2])));
+ }
+
+ position.setNetwork(network);
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());