diff options
author | James <jamejo@gmail.com> | 2021-06-03 15:02:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 15:02:53 -0400 |
commit | 33f400ecd9386e4551565385a9db66f95d484909 (patch) | |
tree | f5dbb3c0e529a20ef5e27ad68807e92276a32ebf | |
parent | 60467dccc46dfdd3b32b342ead40652774f96451 (diff) | |
download | trackermap-server-33f400ecd9386e4551565385a9db66f95d484909.tar.gz trackermap-server-33f400ecd9386e4551565385a9db66f95d484909.tar.bz2 trackermap-server-33f400ecd9386e4551565385a9db66f95d484909.zip |
Support for Type - MicTrack
Support Type value for MicTrack protocol
-rw-r--r-- | src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java index 029e7d99c..ca31eabf7 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) throws ParseException { + private void decodeLocation(Position position, String data, String type) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -99,6 +99,7 @@ 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); } @@ -121,7 +122,7 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { } } - private void decodeNetwork(Position position, String data, boolean hasWifi, boolean hasCell) throws ParseException { + private void decodeNetwork(Position position, String data, String type, boolean hasWifi, boolean hasCell) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -142,10 +143,11 @@ 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) throws ParseException { + private void decodeStatus(Position position, String data, String type) throws ParseException { int index = 0; String[] values = data.split("\\+"); @@ -158,6 +160,7 @@ 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); } @@ -227,21 +230,21 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { switch (fragments[3]) { case "R0": - decodeLocation(position, fragments[4]); + decodeLocation(position, fragments[4], fragments[1]); break; case "R1": - decodeNetwork(position, fragments[4], true, false); + decodeNetwork(position, fragments[4], fragments[1], true, false); break; case "R2": case "R3": - decodeNetwork(position, fragments[4], false, true); + decodeNetwork(position, fragments[4], fragments[1], false, true); break; case "R12": case "R13": - decodeNetwork(position, fragments[4], true, true); + decodeNetwork(position, fragments[4], fragments[1], true, true); break; case "RH": - decodeStatus(position, fragments[4]); + decodeStatus(position, fragments[4], fragments[1]); break; default: return null; |