aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/LaipacProtocolDecoder.java
diff options
context:
space:
mode:
authorKevin Goos <kevingoos@telenet.be>2018-03-20 16:25:29 +0100
committerKevin Goos <kevingoos@telenet.be>2018-03-20 16:25:29 +0100
commit11a5078af4f323f7132a50f3838c02b6e7f71a42 (patch)
tree2ddc80b97ad49b4ca6f5adc68fe1ae2a18f1bbfb /src/org/traccar/protocol/LaipacProtocolDecoder.java
parent2ff1d912fad21a8b5014459300221171c3b836d2 (diff)
downloadtrackermap-server-11a5078af4f323f7132a50f3838c02b6e7f71a42.tar.gz
trackermap-server-11a5078af4f323f7132a50f3838c02b6e7f71a42.tar.bz2
trackermap-server-11a5078af4f323f7132a50f3838c02b6e7f71a42.zip
Switched network to differnt object
Diffstat (limited to 'src/org/traccar/protocol/LaipacProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index 5221e46ad..e7698dc95 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -122,13 +122,17 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 1, parser.nextDouble() * 0.001);
position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001);
- int cellNetCode = Integer.parseInt(parser.next(), 16);
- Long cellId = Long.parseLong(parser.next(), 16);
- int countryCode = parser.nextInt();
-
- position.setNetwork(new Network(CellTower.from(countryCode, cellNetCode, 0, cellId)));
-
- setNextValue(parser, position, Position.KEY_OPERATOR);
+ String cellNetCodeString = parser.next();
+ String cellIdString = parser.next();
+ String countryCodeString = parser.next();
+ String operatorCodeString = parser.next();
+ if (cellNetCodeString != null && cellIdString != null && countryCodeString != null && operatorCodeString != null) {
+ int cellNetCode = Integer.parseInt(cellNetCodeString, 16);
+ Long cellId = Long.parseLong(cellIdString, 16);
+ int countryCode = Integer.parseInt(countryCodeString);
+ int operatorCode = Integer.parseInt(operatorCodeString);
+ position.setNetwork(new Network(CellTower.from(countryCode, operatorCode, cellNetCode, cellId)));
+ }
String checksum = parser.next();
String result = sentence.replaceAll("^\\$(.*)\\*[0-9a-fA-F]{2}$", "$1");
@@ -154,13 +158,6 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private void setNextValue(Parser parser, Position position, String key) {
- String value = parser.next();
- if (value != null) {
- position.set(key, value);
- }
- }
-
private String decodeAlarm(String event) {
if (event.equals('Z')) {
return Position.ALARM_LOW_BATTERY;