aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-04-08 16:16:05 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-04-08 16:16:05 +1200
commitf0c990d0cfc727b25f5de4b1097864d4afadb9cb (patch)
tree15c68b1e0e7e819ef4d2467327d59e5b9db634fc /src
parent62a584aea59666bd95d0a88e917f24fe5999df16 (diff)
downloadtrackermap-server-f0c990d0cfc727b25f5de4b1097864d4afadb9cb.tar.gz
trackermap-server-f0c990d0cfc727b25f5de4b1097864d4afadb9cb.tar.bz2
trackermap-server-f0c990d0cfc727b25f5de4b1097864d4afadb9cb.zip
Add support for TAIP attributes
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 202b9dd63..3611544d5 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.traccar.helper.DateUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.Event;
import org.traccar.model.Position;
public class TaipProtocolDecoder extends BaseProtocolDecoder {
@@ -78,7 +79,6 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
- // Find message start
int beginIndex = sentence.indexOf('>');
if (beginIndex != -1) {
sentence = sentence.substring(beginIndex + 1);
@@ -138,6 +138,54 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.setValid(parser.nextInt() != 0);
+ String[] attributes = null;
+ beginIndex = sentence.indexOf(';');
+ if (beginIndex != -1) {
+ int endIndex = sentence.indexOf('<', beginIndex);
+ if (endIndex == -1) {
+ endIndex = sentence.length();
+ }
+ attributes = sentence.substring(beginIndex, endIndex).split(";");
+ }
+
+ if (attributes != null) {
+ for (String attribute : attributes) {
+ int index = attribute.indexOf('=');
+ if (index != -1) {
+ String key = attribute.substring(0, index).toLowerCase();
+ String value = attribute.substring(index + 1);
+ switch (key) {
+
+ case "id":
+ if (!identify(value, channel, remoteAddress)) {
+ return null;
+ }
+ if (sendResponse && channel != null) {
+ channel.write(value);
+ }
+ break;
+
+ case "sv":
+ position.set(Event.KEY_SATELLITES, value);
+ break;
+
+ case "bl":
+ position.set(Event.KEY_BATTERY, value);
+ break;
+
+ case "vo":
+ position.set(Event.KEY_ODOMETER, value);
+ break;
+
+ default:
+ position.set(key, value);
+ break;
+
+ }
+ }
+ }
+ }
+
return position;
}