aboutsummaryrefslogtreecommitdiff
path: root/src/net/sourceforge/opentracking/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/opentracking/protocol')
-rw-r--r--src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java71
-rw-r--r--src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java3
-rw-r--r--src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java3
-rw-r--r--src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java7
4 files changed, 38 insertions, 46 deletions
diff --git a/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java
index 0b7166ab2..6d0e0a8d9 100644
--- a/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java
+++ b/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java
@@ -58,19 +58,22 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder {
* Regular expressions pattern
*/
static private Pattern pattern = Pattern.compile(
- "imei:" +
- "([\\d]+)," + // IMEI
- "[^,]+," +
- "(\\d{2})(\\d{2})(\\d{2})[\\d]+," + // Date
- "[+]?[\\d]*," +
- "[FL]," + // F - full / L - low
- "([\\d]{2})([\\d]{2})([\\d]{2}).([\\d]{3})," + // Time (HHMMSS.SSS)
- "([AV])," + // Validity
- "([\\d]{2})([\\d]{2}.[\\d]{4})," + // Latitude (DDMM.MMMM)
- "([NS])," +
- "([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM)
- "([EW])," +
- "([\\d]+.[\\d]{2}),"); // Speed
+ "\\+RESP:GT...," +
+ "\\d{6}," + // Protocol version
+ "(\\d{15})," + // IMEI
+ "[^,]*," + // Device name
+ "\\d," + // Report ID
+ "\\d," + // Report type
+ "\\d*," + // Number
+ "(\\d*)," + // GPS accuracy
+ "(\\d+.\\d)," + // Speed
+ "(\\d+)," + // Course
+ "(-?\\d+.\\d)," + // Altitude
+ "(-?\\d+.\\d+)," + // Longitude
+ "(-?\\d+.\\d+)," + // Latitude
+ "(\\d{4})(\\d{2})(\\d{2})" + // Date (YYYYMMDD)
+ "(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS)
+ "[^$]*");
/**
* Decode message
@@ -81,16 +84,6 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder {
String sentence = (String) msg;
- // Send response #1
- if (sentence.contains("##")) {
- channel.write("LOAD");
- }
-
- // Send response #2
- if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) {
- channel.write("ON");
- }
-
// Parse message
Matcher parser = pattern.matcher(sentence);
if (!parser.matches()) {
@@ -106,10 +99,20 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder {
String imei = parser.group(index++);
position.setDeviceId(dataManager.getDeviceByImei(imei).getId());
+ // Validity
+ position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
+
+ // Position info
+ position.setSpeed(Double.valueOf(parser.group(index++)));
+ position.setCourse(Double.valueOf(parser.group(index++)));
+ position.setAltitude(Double.valueOf(parser.group(index++)));
+ position.setLongitude(Double.valueOf(parser.group(index++)));
+ position.setLatitude(Double.valueOf(parser.group(index++)));
+
// Date
Calendar time = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
time.clear();
- time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
+ time.set(Calendar.YEAR, Integer.valueOf(parser.group(index++)));
time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
@@ -117,28 +120,8 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder {
time.set(Calendar.HOUR, Integer.valueOf(parser.group(index++)));
time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
- // Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
-
- // Latitude
- Double latitude = Double.valueOf(parser.group(index++));
- latitude += Double.valueOf(parser.group(index++)) / 60;
- if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
- position.setLatitude(latitude);
-
- // Longitude
- Double lonlitude = Double.valueOf(parser.group(index++));
- lonlitude += Double.valueOf(parser.group(index++)) / 60;
- if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
- position.setLongitude(lonlitude);
-
- // Speed
- position.setSpeed(Double.valueOf(parser.group(index++)));
- position.setCourse(0.0);
-
return position;
}
diff --git a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java
index faccc97d7..c9d8e2da1 100644
--- a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java
+++ b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java
@@ -134,6 +134,9 @@ public class Gps103ProtocolDecoder extends OneToOneDecoder {
lonlitude += Double.valueOf(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
+
+ // Altitude
+ position.setAltitude(0.0);
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
diff --git a/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java
index 2ff6ce949..79350307c 100644
--- a/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java
+++ b/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java
@@ -126,6 +126,9 @@ public class Tk103ProtocolDecoder extends OneToOneDecoder {
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
+ // Altitude
+ position.setAltitude(0.0);
+
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
diff --git a/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
index afd2405c8..73b7cef11 100644
--- a/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
+++ b/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
@@ -66,8 +66,8 @@ public class XexunProtocolDecoder extends OneToOneDecoder {
"([NS])," +
"([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM)
"([EW])," +
- "([\\d]+.[\\d]{2})," + // Speed
- "([\\d]+.[\\d]{2})?," + // Course
+ "([\\d]+.[\\d]+)," + // Speed
+ "([\\d]+.[\\d]+)?," + // Course
"([\\d]{2})([\\d]{2})([\\d]{2})," + // Date (DDMMYY)
".*imei:" +
"([\\d]+),"); // IMEI
@@ -114,6 +114,9 @@ public class XexunProtocolDecoder extends OneToOneDecoder {
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
+ // Altitude
+ position.setAltitude(0.0);
+
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));