From 69200d5d68bbd4ed5b5c6b10d4231f365b10db80 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 2 Sep 2015 15:28:56 +1200 Subject: Add panic status code --- src/org/traccar/WebDataHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/org') diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index 5f12b9c93..6a359ba0f 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -21,6 +21,7 @@ import java.util.Locale; import java.util.TimeZone; import org.traccar.helper.Crc; import org.traccar.model.Device; +import org.traccar.model.Event; import org.traccar.model.Position; public class WebDataHandler extends BaseDataHandler { @@ -56,6 +57,16 @@ public class WebDataHandler extends BaseDataHandler { return s.toString(); } + private String calculateStatus(Position position) { + if (position.getOther().containsKey(Event.KEY_ALARM) && (Boolean) position.getOther().get(Event.KEY_ALARM)) { + return "0xF841"; // STATUS_PANIC_ON + } else if (position.getSpeed() < 1.0) { + return "0xF020"; // STATUS_LOCATION + } else { + return "0xF11C"; // STATUS_MOTION_MOVING + } + } + @Override protected Position handlePosition(Position position) { @@ -68,7 +79,7 @@ public class WebDataHandler extends BaseDataHandler { .replace("{latitude}", String.valueOf(position.getLatitude())) .replace("{longitude}", String.valueOf(position.getLongitude())) .replace("{gprmc}", formatSentence(position)) - .replace("{statusCode}", position.getSpeed() < 1.0 ? "0xF020" : "0xF11C"); + .replace("{statusCode}", calculateStatus(position)); Context.getAsyncHttpClient().prepareGet(request).execute(); -- cgit v1.2.3