diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/OwnTracksProtocolDecoder.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java index b0a40e4fc..9dead6344 100644 --- a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java +++ b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java @@ -115,11 +115,11 @@ public class OwnTracksProtocolDecoder extends BaseHttpProtocolDecoder { if (root.containsKey("t")) { String trigger = root.getString("t"); position.set("t", trigger); - Integer rty = -1; + Integer reportType = -1; if (root.containsKey("rty")) { - rty = root.getInt("rty"); + reportType = root.getInt("rty"); } - setEventOrAlarm(position, trigger, rty); + setEventOrAlarm(position, trigger, reportType); } if (root.containsKey("batt")) { position.set(Position.KEY_BATTERY_LEVEL, root.getInt("batt")); @@ -153,8 +153,8 @@ public class OwnTracksProtocolDecoder extends BaseHttpProtocolDecoder { } if (root.containsKey("anum")) { - Integer anum = root.getInt("anum"); - for (Integer i = 0; i < anum; i++) { + Integer numberOfAnalogueInputs = root.getInt("anum"); + for (Integer i = 0; i < numberOfAnalogueInputs; i++) { String indexString = String.format("%02d", i); if (root.containsKey("adda-" + indexString)) { position.set(Position.PREFIX_ADC + (i + 1), root.getString("adda-" + indexString)); @@ -170,32 +170,25 @@ public class OwnTracksProtocolDecoder extends BaseHttpProtocolDecoder { return position; } - private void setEventOrAlarm(Position position, String trigger, Integer rty) { + private void setEventOrAlarm(Position position, String trigger, Integer reportType) { if (trigger.equals("9")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); } else if (trigger.equals("1")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_POWER_ON); } else if (trigger.equals("i")) { position.set(Position.KEY_IGNITION, true); } else if (trigger.equals("I")) { position.set(Position.KEY_IGNITION, false); } else if (trigger.equals("E")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_POWER_RESTORED); } else if (trigger.equals("e")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); } else if (trigger.equals("!")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_TOW); } else if (trigger.equals("s")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); } else if (trigger.equals("h")) { - position.set(Position.KEY_EVENT, Event.TYPE_ALARM); - switch (rty) { + switch (reportType) { case 0: case 3: position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); |