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 | |
parent | f61f79c2068c7ed384247107543f27dd19ee2a5a (diff) | |
download | trackermap-server-f06ef203a480f0184e97daa64432e4e777e1b95f.tar.gz trackermap-server-f06ef203a480f0184e97daa64432e4e777e1b95f.tar.bz2 trackermap-server-f06ef203a480f0184e97daa64432e4e777e1b95f.zip |
Decode PT60 cell information
-rw-r--r-- | src/org/traccar/protocol/Pt60ProtocolDecoder.java | 35 | ||||
-rw-r--r-- | test/org/traccar/protocol/Pt60ProtocolDecoderTest.java | 5 |
2 files changed, 35 insertions, 5 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; diff --git a/test/org/traccar/protocol/Pt60ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt60ProtocolDecoderTest.java index f41ff90e6..c96bf9c3b 100644 --- a/test/org/traccar/protocol/Pt60ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Pt60ProtocolDecoderTest.java @@ -10,8 +10,11 @@ public class Pt60ProtocolDecoderTest extends ProtocolTest { Pt60ProtocolDecoder decoder = new Pt60ProtocolDecoder(null); + verifyNotNull(decoder, text( + "@B#@|01|001|864891030184852|9425010450971470|1|84|20181205161005|40412,10461,1,425,10|2|")); + verifyPosition(decoder, text( - "@B#@|01|001|864891030184852|9425010450971470|1|45|20181127122717|32.701093|35.570938|1|@E#@")); + "@B#@|01|001|864891030184852|9425010450971470|1|45|20181127122717|32.701093|35.570938|1|")); verifyNull(decoder, text( "@B#@|01|003|864891030184954|9425010450971470|S6_EN_A_V1.3.7|0|66|20181122113251|40412,10461,1,425,18|49382,10461,1,425,9|40411,10461,1,425,7|2|")); |