aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java
index 4a23d57d0..5f9326a61 100644
--- a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java
@@ -31,6 +31,7 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
import org.traccar.model.Position;
+import org.traccar.model.WifiAccessPoint;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
@@ -74,6 +75,37 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private static final Pattern PATTERN_NEW = new PatternBuilder()
+ .text("$$")
+ .number("d+,") // length
+ .number("(d+),") // imei
+ .number("x+,") // index
+ .text("A03,") // type
+ .number("(d+)?,") // alarm
+ .number("(dd)(dd)(dd)") // date (yymmdd)
+ .number("(dd)(dd)(dd),") // time (hhmmss)
+ .number("(d+)|") // mcc
+ .number("(d+)|") // mnc
+ .number("(x+)|") // lac
+ .number("(x+),") // cid
+ .number("(d+.d+),") // battery
+ .number("(d+),") // battery level
+ .number("(x+),") // status
+ .groupBegin()
+ .text("0,") // gps location
+ .number("([AV]),") // validity
+ .number("(d+),") // speed
+ .number("(d+),") // satellites
+ .number("(-?d+.d+),") // latitude
+ .number("(-?d+.d+)") // longitude
+ .or()
+ .text("1,") // wifi location
+ .expression("([^*]+)") // wifi
+ .groupEnd()
+ .text("*")
+ .number("xx") // checksum
+ .compile();
+
private static final Pattern PATTERN_PHOTO = new PatternBuilder()
.text("$$")
.number("d+,") // length
@@ -160,6 +192,61 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+
+ private Object decodeLocationNew(
+ Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_NEW, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt()));
+
+ position.setDeviceTime(parser.nextDateTime());
+
+ Network network = new Network();
+ network.addCellTower(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextHexInt(), parser.nextHexInt()));
+
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
+ position.set(Position.KEY_STATUS, parser.nextHexInt());
+
+ if (parser.hasNext(5)) {
+
+ position.setValid(parser.next().equals("A"));
+ position.setFixTime(position.getDeviceTime());
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
+ position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
+
+ } else {
+
+ String[] points = parser.next().split("\\|");
+ for (String point : points) {
+ String[] wifi = point.split(":");
+ String mac = wifi[0].replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), Integer.parseInt(wifi[1])));
+ }
+
+ }
+
+ position.setNetwork(network);
+
+ return position;
+ }
+
private Object decodeLocation(
Channel channel, SocketAddress remoteAddress, String sentence) {
@@ -301,6 +388,10 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ } else if (type.equals("A03")) {
+
+ return decodeLocationNew(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII));
+
} else {
return decodeLocation(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII));