diff options
Diffstat (limited to 'src/org/traccar/protocol/TaipProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/TaipProtocolDecoder.java | 50 |
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; } |