aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2019-07-16 12:04:50 -0400
committerEdward Valley <ed.valley@yandex.com>2019-07-16 12:04:50 -0400
commit84fd882f8a9ca7d1e90cd5f40dfe04979498e7f5 (patch)
tree65576d029b38b9c8e35ba42f3af96436eab269bf
parentd60f27310aa094b8b58b66a5833e639cd45f4f93 (diff)
downloadtraccar-server-84fd882f8a9ca7d1e90cd5f40dfe04979498e7f5.tar.gz
traccar-server-84fd882f8a9ca7d1e90cd5f40dfe04979498e7f5.tar.bz2
traccar-server-84fd882f8a9ca7d1e90cd5f40dfe04979498e7f5.zip
Changes after second review
-rw-r--r--src/main/java/org/traccar/model/Position.java2
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java16
-rw-r--r--src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java2
3 files changed, 6 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java
index 51743d0de..2c0e22c9e 100644
--- a/src/main/java/org/traccar/model/Position.java
+++ b/src/main/java/org/traccar/model/Position.java
@@ -84,7 +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_PHONE = "phone";
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 924725041..2185b707e 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -44,9 +44,9 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
.text("$EAVSYS,")
.expression("([^,]+),") // identifier
.expression("([0-9]+),") // iccid
- .expression("(\\+?[0-9]*),") // sim phone number
+ .expression("(\\+?[0-9]+)?,") // sim phone number
.expression("(?:[^,]*),") // owner name
- .expression("([^,]*)") // firmware version
+ .expression("([^,]*)?") // firmware version
.text("*")
.number("(xx)") // checksum
.compile();
@@ -189,16 +189,8 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_ICCID, parser.next());
-
- String phoneNumber = parser.next();
- if (!phoneNumber.isEmpty()) {
- position.set(Position.KEY_PHONE_NUMBER, phoneNumber);
- }
-
- String firmware = parser.next();
- if (!firmware.isEmpty()) {
- position.set(Position.KEY_VERSION_FW, firmware);
- }
+ position.set(Position.KEY_PHONE, parser.next());
+ position.set(Position.KEY_VERSION_FW, parser.next());
return position;
}
diff --git a/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java
index 1cbf50e2c..5b66ed865 100644
--- a/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java
@@ -22,7 +22,7 @@ public class LaipacProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, text(
"$AVSYS,MSG00002,14406,7046811160,64*1A"));
- verifyNotNull(decoder, text(
+ verifyAttributes(decoder, text(
"$EAVSYS,MSG00002,8931086013104404999,,Owner,0x52014406*76"));
verifyNull(decoder, text(