diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-03 21:04:17 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-03 21:04:17 -0700 |
commit | aba0e3c0732046ec92676966dc53e147de11f32d (patch) | |
tree | 8378d785bb2eea5d20d49297044ed04376d35dc3 /src/main | |
parent | 33f400ecd9386e4551565385a9db66f95d484909 (diff) | |
download | trackermap-server-aba0e3c0732046ec92676966dc53e147de11f32d.tar.gz trackermap-server-aba0e3c0732046ec92676966dc53e147de11f32d.tar.bz2 trackermap-server-aba0e3c0732046ec92676966dc53e147de11f32d.zip |
Set type is a single place
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java index ca31eabf7..992b5c43a 100644 --- a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java @@ -83,7 +83,7 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { } } - private void decodeLocation(Position position, String data, String type) throws ParseException { + private void decodeLocation(Position position, String data) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -99,7 +99,6 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { int event = Integer.parseInt(values[index++]); position.set(Position.KEY_ALARM, decodeAlarm(event)); position.set(Position.KEY_EVENT, event); - position.set(Position.KEY_TYPE, Integer.parseInt(type)); position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.001); } @@ -122,7 +121,7 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { } } - private void decodeNetwork(Position position, String data, String type, boolean hasWifi, boolean hasCell) throws ParseException { + private void decodeNetwork(Position position, String data, boolean hasWifi, boolean hasCell) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -143,11 +142,10 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { int event = Integer.parseInt(values[index++]); position.set(Position.KEY_ALARM, decodeAlarm(event)); position.set(Position.KEY_EVENT, event); - position.set(Position.KEY_TYPE, Integer.parseInt(type)); position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.001); } - private void decodeStatus(Position position, String data, String type) throws ParseException { + private void decodeStatus(Position position, String data) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -160,7 +158,6 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { int event = Integer.parseInt(values[index++]); position.set(Position.KEY_ALARM, decodeAlarm(event)); position.set(Position.KEY_EVENT, event); - position.set(Position.KEY_TYPE, Integer.parseInt(type)); position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.001); } @@ -179,7 +176,7 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { } private Object decodeResult( - Channel channel, SocketAddress remoteAddress, String sentence) throws Exception { + Channel channel, SocketAddress remoteAddress, String sentence) { if (sentence.matches("\\d{15} .+")) { @@ -227,24 +224,25 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.set(Position.KEY_TYPE, Integer.parseInt(fragments[1])); switch (fragments[3]) { case "R0": - decodeLocation(position, fragments[4], fragments[1]); + decodeLocation(position, fragments[4]); break; case "R1": - decodeNetwork(position, fragments[4], fragments[1], true, false); + decodeNetwork(position, fragments[4], true, false); break; case "R2": case "R3": - decodeNetwork(position, fragments[4], fragments[1], false, true); + decodeNetwork(position, fragments[4], false, true); break; case "R12": case "R13": - decodeNetwork(position, fragments[4], fragments[1], true, true); + decodeNetwork(position, fragments[4], true, true); break; case "RH": - decodeStatus(position, fragments[4], fragments[1]); + decodeStatus(position, fragments[4]); break; default: return null; |