aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/SuntechProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/SuntechProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index 6dfc6f77f..b739e699b 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -76,8 +78,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
if (type.equals("Emergency") || type.equals("Alert")) {
@@ -157,7 +158,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Position decode235(
+ private Position decode2356(
Channel channel, SocketAddress remoteAddress, String protocol, String[] values) throws ParseException {
int index = 0;
@@ -172,12 +173,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_TYPE, type);
- if (protocol.equals("ST300") || protocol.equals("ST500")) {
+ if (protocol.equals("ST300") || protocol.equals("ST500") || protocol.equals("ST600")) {
index += 1; // model
}
@@ -188,7 +188,12 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateFormat.parse(values[index++] + values[index++]));
if (!protocol.equals("ST500")) {
- index += 1; // cell
+ int cid = Integer.parseInt(values[index++], 16);
+ if (protocol.equals("ST600")) {
+ position.setNetwork(new Network(CellTower.from(
+ Integer.parseInt(values[index++]), Integer.parseInt(values[index++]),
+ Integer.parseInt(values[index++], 16), cid, Integer.parseInt(values[index++]))));
+ }
}
position.setLatitude(Double.parseDouble(values[index++]));
@@ -289,8 +294,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_TYPE, type);
@@ -372,7 +376,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
} else if (values[0].equals("ST910")) {
return decode9(channel, remoteAddress, values);
} else {
- return decode235(channel, remoteAddress, values[0].substring(0, 5), values);
+ return decode2356(channel, remoteAddress, values[0].substring(0, 5), values);
}
}