aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MeitrackProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:16:14 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:16:14 +1200
commit81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b (patch)
treece4d0b24f1c82381da30472844052f8cfdc1a164 /src/org/traccar/protocol/MeitrackProtocolDecoder.java
parentf367b71b9c081416f6d64f6efd9844cd05f047ea (diff)
downloadtrackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.gz
trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.bz2
trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.zip
Fix extended info XML format
Diffstat (limited to 'src/org/traccar/protocol/MeitrackProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 87d222c37..e3b5187f4 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -24,23 +24,15 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
-/**
- * Meitrack protocol decoder
- */
public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public MeitrackProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
- /**
- * Regular expressions pattern
- */
static private Pattern pattern = Pattern.compile(
"\\$\\$." + // Flag
"\\d+," + // Length
@@ -61,9 +53,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)," + // Milage
".*"); // TODO: parse other stuff
- /**
- * Decode message
- */
+ @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
@@ -77,7 +67,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- StringBuilder extendedInfo = new StringBuilder("<protocol>meitrack</protocol>");
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meitrack");
Integer index = 1;
@@ -91,9 +81,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
// Event
- extendedInfo.append("<event>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</event>");
+ extendedInfo.set("event", parser.group(index++));
// Coordinates
position.setLatitude(Double.valueOf(parser.group(index++)));
@@ -114,14 +102,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
// Satellites
- extendedInfo.append("<satellites>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</satellites>");
+ extendedInfo.set("satellites", parser.group(index++));
// GSM Signal
- extendedInfo.append("<gsm>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</gsm>");
+ extendedInfo.set("gsm", parser.group(index++));
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
@@ -130,17 +114,13 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(Double.valueOf(parser.group(index++)));
// HDOP
- extendedInfo.append("<hdop>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</hdop>");
+ extendedInfo.set("hdop", parser.group(index++));
// Altitude
position.setAltitude(Double.valueOf(parser.group(index++)));
// Milage
- extendedInfo.append("<milage>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</milage>");
+ extendedInfo.set("milage", parser.group(index++));
// Extended info
position.setExtendedInfo(extendedInfo.toString());