aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-11-02 20:47:48 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-11-02 20:47:48 -0800
commit9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead (patch)
treebe1d1d42d5766a5926c98d36260fd3191503fccd
parent5516ec3057eb3a38ad4b7bc42212afbac6d11adc (diff)
downloadtrackermap-server-9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead.tar.gz
trackermap-server-9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead.tar.bz2
trackermap-server-9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead.zip
Alternative smart crutches format
-rw-r--r--src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java40
-rw-r--r--src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java4
-rw-r--r--src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java6
3 files changed, 41 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java b/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java
index 4b0f46e34..c2f3781d9 100644
--- a/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java
@@ -43,8 +43,13 @@ public class FutureWayProtocolDecoder extends BaseProtocolDecoder {
.expression("([AV]),") // validity
.number("(dd)(dd)(dd)") // date (yymmdd)
.number("(dd)(dd)(dd),") // time (hhmmss)
+ .groupBegin()
+ .number("(dd)(dd.d+)([NS]),") // latitude
+ .number("(ddd)(dd.d+)([EW]),") // longitude
+ .or()
.number("(d+.d+)([NS]),") // latitude
.number("(d+.d+)([EW]),") // longitude
+ .groupEnd()
.number("(d+.d+),") // speed
.number("(d+.d+)") // course
.compile();
@@ -90,27 +95,44 @@ public class FutureWayProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setTime(parser.nextDateTime());
- position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
+
+ if (parser.hasNext(6)) {
+ position.setLatitude(parser.nextCoordinate());
+ position.setLongitude(parser.nextCoordinate());
+ }
+
+ if (parser.hasNext(4)) {
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
+ }
+
position.setSpeed(parser.nextDouble());
position.setCourse(parser.nextDouble());
} else if (line.startsWith("WIFI")) {
- for (String item : line.substring(line.indexOf(',') + 1).split("&")) {
- String[] values = item.split("\\|");
- network.addWifiAccessPoint(
- WifiAccessPoint.from(values[1].replace('-', ':'), Integer.parseInt(values[2])));
+ if (line.contains(",")) {
+ for (String item : line.substring(line.indexOf(',') + 1).split("&")) {
+ String[] values = item.split("\\|");
+ network.addWifiAccessPoint(
+ WifiAccessPoint.from(values[1].replace('-', ':'), Integer.parseInt(values[2])));
+ }
}
} else if (line.startsWith("LBS")) {
String[] values = line.substring("LBS:".length()).split(",");
+ int lac, cid;
+ if (Integer.parseInt(values[2]) > 65535) {
+ cid = Integer.parseInt(values[2]);
+ lac = Integer.parseInt(values[3]);
+ } else {
+ lac = Integer.parseInt(values[2]);
+ cid = Integer.parseInt(values[3]);
+ }
network.addCellTower(CellTower.from(
Integer.parseInt(values[0]),
- Integer.parseInt(values[1]),
- Integer.parseInt(values[3]),
- Integer.parseInt(values[2])));
+ Integer.parseInt(values[1]), lac, cid));
}
diff --git a/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java b/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java
index fb1e395f1..fb1597474 100644
--- a/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java
@@ -11,6 +11,10 @@ public class FutureWayFrameDecoderTest extends ProtocolTest {
FutureWayFrameDecoder decoder = new FutureWayFrameDecoder();
verifyFrame(
+ binary("343130303030303039424130303030344750533a562c3230303930323039333333332c302e3030303030304e2c302e303030303030452c302e3030302c302e3030300d0a574946493a332c317c39302d36372d31432d46372d32312d36437c353226327c38302d38392d31372d43362d37392d41307c353426337c34302d46342d32302d45462d44442d32417c35380d0a4c42533a3436302c302c34363437353036362c36390d0a36413432"),
+ decoder.decode(null, null, binary("343130303030303039424130303030344750533a562c3230303930323039333333332c302e3030303030304e2c302e303030303030452c302e3030302c302e3030300d0a574946493a332c317c39302d36372d31432d46372d32312d36437c353226327c38302d38392d31372d43362d37392d41307c353426337c34302d46342d32302d45462d44442d32417c35380d0a4c42533a3436302c302c34363437353036362c36390d0a36413432")));
+
+ verifyFrame(
binary("34313030303030303346323030303032302c494d45493a3335343832383130303132363436312c62617474657279206c6576656c3a362c6e6574776f726b20747970653a372c4353513a323336463432"),
decoder.decode(null, null, binary("34313030303030303346323030303032302c494d45493a3335343832383130303132363436312c62617474657279206c6576656c3a362c6e6574776f726b20747970653a372c4353513a323336463432")));
diff --git a/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java
index 951b3bb20..e3df385df 100644
--- a/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java
@@ -13,6 +13,12 @@ public class FutureWayProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, text(
"410000003F2000020,IMEI:354828100126461,battery level:6,network type:7,CSQ:236F42"));
+ verifyNull(decoder, text(
+ "41000000622000020,IMEI:354828100002140,battery level:32,network type:7,CSQ:18,Version:FWS03.APP.SVN144.202010231442"));
+
+ verifyPosition(decoder, text(
+ "4100000092A00004\r\nIMEI:354828100002140\r\nGPS:A,201102090140,2233.246582N,11356.300781E,0.000,0.000\r\nWIFI:\r\nLBS:460,0,9763,219992654\r\nbattery level:32\r\nSteps:0\r\n4F42"));
+
verifyPosition(decoder, text(
"410000009BA00004GPS:V,200902093333,0.000000N,0.000000E,0.000,0.000\r\nWIFI:3,1|90-67-1C-F7-21-6C|52&2|80-89-17-C6-79-A0|54&3|40-F4-20-EF-DD-2A|58\r\nLBS:460,0,46475066,69\r\n6A42"));