diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-02 22:16:14 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-02 22:16:14 +1200 |
commit | 81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b (patch) | |
tree | ce4d0b24f1c82381da30472844052f8cfdc1a164 /src/org/traccar/protocol/Gt06ProtocolDecoder.java | |
parent | f367b71b9c081416f6d64f6efd9844cd05f047ea (diff) | |
download | traccar-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.gz traccar-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.bz2 traccar-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.zip |
Fix extended info XML format
Diffstat (limited to 'src/org/traccar/protocol/Gt06ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 741841a11..a0113b362 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -25,6 +25,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.ServerManager; import org.traccar.helper.Crc; import org.traccar.helper.Log; +import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Gt06ProtocolDecoder extends BaseProtocolDecoder { @@ -108,7 +109,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - StringBuilder extendedInfo = new StringBuilder("<protocol>gt06</protocol>"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gt06"); // Date and time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -123,9 +124,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // GPS length and Satellites count int gpsLength = buf.readUnsignedByte(); - extendedInfo.append("<satellites>"); - extendedInfo.append(gpsLength & 0xf); - extendedInfo.append("</satellites>"); + extendedInfo.set("satellites", gpsLength & 0xf); gpsLength >>= 4; // Latitude @@ -158,32 +157,22 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } // Cell information - extendedInfo.append("<mcc>"); - extendedInfo.append(buf.readUnsignedShort()); - extendedInfo.append("</mcc>"); - extendedInfo.append("<mnc>"); - extendedInfo.append(buf.readUnsignedByte()); - extendedInfo.append("</mnc>"); - extendedInfo.append("<lac>"); - extendedInfo.append(buf.readUnsignedShort()); - extendedInfo.append("</lac>"); - extendedInfo.append("<cell>"); - extendedInfo.append(buf.readUnsignedShort() << 8 + buf.readUnsignedByte()); - extendedInfo.append("</cell>"); + extendedInfo.set("mcc", buf.readUnsignedShort()); + extendedInfo.set("mnc", buf.readUnsignedByte()); + extendedInfo.set("lac", buf.readUnsignedShort()); + extendedInfo.set("cell", buf.readUnsignedShort() << 8 + buf.readUnsignedByte()); buf.skipBytes(lbsLength - 9); // Status if (type == MSG_GPS_LBS_STATUS) { int flags = buf.readUnsignedByte(); // TODO parse flags - extendedInfo.append("<alarm>true</alarm>"); + extendedInfo.set("alarm", true); // Voltage position.setPower((double) buf.readUnsignedByte()); // GSM signal - extendedInfo.append("<gsm>"); - extendedInfo.append(buf.readUnsignedByte()); - extendedInfo.append("</gsm>"); + extendedInfo.set("gsm", buf.readUnsignedByte()); } } |