aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2019-07-16 10:05:37 -0400
committerEdward Valley <ed.valley@yandex.com>2019-07-16 10:05:37 -0400
commitd60f27310aa094b8b58b66a5833e639cd45f4f93 (patch)
treeb5eef2acb2e3f4ce2b33f635b5f0329d9c7668ef /src/main/java/org/traccar
parent646a9874c7a18d032627360bbcf948bf154a0ead (diff)
downloadtraccar-server-d60f27310aa094b8b58b66a5833e639cd45f4f93.tar.gz
traccar-server-d60f27310aa094b8b58b66a5833e639cd45f4f93.tar.bz2
traccar-server-d60f27310aa094b8b58b66a5833e639cd45f4f93.zip
Changes after first review
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/BaseProtocolDecoder.java7
-rw-r--r--src/main/java/org/traccar/model/Position.java1
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java27
3 files changed, 14 insertions, 21 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java
index f0642f509..aa5be612e 100644
--- a/src/main/java/org/traccar/BaseProtocolDecoder.java
+++ b/src/main/java/org/traccar/BaseProtocolDecoder.java
@@ -184,9 +184,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
}
- public boolean getLastLocation(Position position, Date deviceTime) {
- boolean found = false;
-
+ public void getLastLocation(Position position, Date deviceTime) {
if (position.getDeviceId() != 0) {
position.setOutdated(true);
@@ -200,7 +198,6 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
position.setSpeed(last.getSpeed());
position.setCourse(last.getCourse());
position.setAccuracy(last.getAccuracy());
- found = true;
} else {
position.setFixTime(new Date(0));
}
@@ -211,8 +208,6 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
position.setDeviceTime(new Date());
}
}
-
- return found;
}
@Override
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java
index 4c28ae59b..51743d0de 100644
--- a/src/main/java/org/traccar/model/Position.java
+++ b/src/main/java/org/traccar/model/Position.java
@@ -84,6 +84,7 @@ public class Position extends Message {
public static final String KEY_AXLE_WEIGHT = "axleWeight";
public static final String KEY_G_SENSOR = "gSensor";
public static final String KEY_ICCID = "iccid";
+ public static final String KEY_PHONE_NUMBER = "phoneNumber";
public static final String KEY_DTCS = "dtcs";
public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
index 13451f798..924725041 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -44,11 +44,9 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
.text("$EAVSYS,")
.expression("([^,]+),") // identifier
.expression("([0-9]+),") // iccid
- .expression("([^,]*),") // reserved
- .expression("([^,]*),") // reserved
- .text("0x")
- .number("(xx)") // product type
- .number("(dd)(dd)(dd)") // firmware version (major, minor, revision)
+ .expression("(\\+?[0-9]*),") // sim phone number
+ .expression("(?:[^,]*),") // owner name
+ .expression("([^,]*)") // firmware version
.text("*")
.number("(xx)") // checksum
.compile();
@@ -188,20 +186,19 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- if (!getLastLocation(position, null)) {
- return null;
- }
+ getLastLocation(position, null);
position.set(Position.KEY_ICCID, parser.next());
- String unused = parser.next();
- unused = parser.next();
+ String phoneNumber = parser.next();
+ if (!phoneNumber.isEmpty()) {
+ position.set(Position.KEY_PHONE_NUMBER, phoneNumber);
+ }
- int hardware = parser.nextHexInt();
- position.set(Position.KEY_VERSION_HW,
- (hardware == 0x12) ? "SF-Lite" : (hardware == 0x52) ? "S911 Lola" : null);
- position.set(Position.KEY_VERSION_FW, String.format("%d.%02d.%02d",
- parser.nextInt(), parser.nextInt(), parser.nextInt()));
+ String firmware = parser.next();
+ if (!firmware.isEmpty()) {
+ position.set(Position.KEY_VERSION_FW, firmware);
+ }
return position;
}