From 11a5078af4f323f7132a50f3838c02b6e7f71a42 Mon Sep 17 00:00:00 2001 From: Kevin Goos Date: Tue, 20 Mar 2018 16:25:29 +0100 Subject: Switched network to differnt object --- .../traccar/protocol/LaipacProtocolDecoder.java | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src') 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; -- cgit v1.2.3