diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-12-06 10:50:58 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-12-06 10:50:58 +1300 |
commit | f06ef203a480f0184e97daa64432e4e777e1b95f (patch) | |
tree | 07fdcd7f30c8a5be8a6c3035e8123bcbfccc810e /src/org/traccar | |
parent | f61f79c2068c7ed384247107543f27dd19ee2a5a (diff) | |
download | traccar-server-f06ef203a480f0184e97daa64432e4e777e1b95f.tar.gz traccar-server-f06ef203a480f0184e97daa64432e4e777e1b95f.tar.bz2 traccar-server-f06ef203a480f0184e97daa64432e4e777e1b95f.zip |
Decode PT60 cell information
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/Pt60ProtocolDecoder.java | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/Pt60ProtocolDecoder.java b/src/org/traccar/protocol/Pt60ProtocolDecoder.java index 75b33b3c7..6a3fe2734 100644 --- a/src/org/traccar/protocol/Pt60ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt60ProtocolDecoder.java @@ -22,6 +22,8 @@ import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; import java.net.SocketAddress; @@ -55,6 +57,7 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder { .number("(dddd)(dd)(dd)") // date (yyyymmdd) .number("(dd)(dd)(dd)[,|]") // time (hhmmss) .expression("(.*)") // data + .expression("[,|]") .compile(); private void sendResponse(Channel channel, SocketAddress remoteAddress, String format, int type, String imei) { @@ -143,11 +146,35 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder { String[] values = parser.next().split("\\|"); - position.setValid(true); - position.setFixTime(position.getDeviceTime()); + if (Integer.parseInt(values[values.length - 1]) == 2) { - position.setLatitude(Double.parseDouble(values[0])); - position.setLongitude(Double.parseDouble(values[1])); + getLastLocation(position, position.getDeviceTime()); + + Network network = new Network(); + + for (int i = 0; i < values.length - 1; i++) { + String[] cellValues = values[i].split(","); + CellTower tower = new CellTower(); + tower.setCellId(Long.parseLong(cellValues[0])); + tower.setLocationAreaCode(Integer.parseInt(cellValues[1])); + tower.setMobileNetworkCode(Integer.parseInt(cellValues[2])); + tower.setMobileCountryCode(Integer.parseInt(cellValues[3])); + tower.setSignalStrength(Integer.parseInt(cellValues[4])); + network.addCellTower(tower); + } + + position.setNetwork(network); + + + } else { + + position.setValid(true); + position.setFixTime(position.getDeviceTime()); + + position.setLatitude(Double.parseDouble(values[0])); + position.setLongitude(Double.parseDouble(values[1])); + + } return position; |