aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-11-02 21:23:14 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-11-02 21:23:14 -0800
commitc2f3554886b62690b2dc705e037517b34da99340 (patch)
tree9e3601171837d35cfef042f23157006a5f8f9f68 /src
parent9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead (diff)
downloadtraccar-server-c2f3554886b62690b2dc705e037517b34da99340.tar.gz
traccar-server-c2f3554886b62690b2dc705e037517b34da99340.tar.bz2
traccar-server-c2f3554886b62690b2dc705e037517b34da99340.zip
More StarLink attributes
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java31
-rw-r--r--src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java5
2 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
index 7ba41ad56..ba079bff0 100644
--- a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.Protocol;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
import org.traccar.model.Position;
@@ -144,6 +145,11 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
String[] dataTags = getFormat(deviceSession.getDeviceId());
DateFormat dateFormat = getDateFormat(deviceSession.getDeviceId());
+ /*
+29.0 (#TVI #),
+0 (#OUTC #),
+ */
+
for (int i = 0; i < Math.min(data.length, dataTags.length); i++) {
if (data[i].isEmpty()) {
continue;
@@ -162,6 +168,9 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, false);
}
break;
+ case "#EDSC#":
+ position.set("reason", data[i]);
+ break;
case "#PDT#":
position.setFixTime(dateFormat.parse(data[i]));
break;
@@ -174,12 +183,21 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
case "#SPD#":
position.setSpeed(Double.parseDouble(data[i]));
break;
+ case "#SPDK#":
+ position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(data[i])));
+ break;
case "#HEAD#":
position.setCourse(Integer.parseInt(data[i]));
break;
case "#ODO#":
position.set(Position.KEY_ODOMETER, (long) (Double.parseDouble(data[i]) * 1000));
break;
+ case "#BATC#":
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(data[i]));
+ break;
+ case "#TVI#":
+ position.set(Position.KEY_DEVICE_TEMP, Double.parseDouble(data[i]));
+ break;
case "#IN1#":
case "#IN2#":
case "#IN3#":
@@ -190,7 +208,13 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
case "#OUT2#":
case "#OUT3#":
case "#OUT4#":
- position.set(Position.PREFIX_OUT + dataTags[i].charAt(3), Integer.parseInt(data[i]));
+ position.set(Position.PREFIX_OUT + dataTags[i].charAt(4), Integer.parseInt(data[i]));
+ break;
+ case "#OUTA#":
+ case "#OUTB#":
+ case "#OUTC#":
+ case "#OUTD#":
+ position.set(Position.PREFIX_OUT + (dataTags[i].charAt(4) - 'A' + 1), Integer.parseInt(data[i]));
break;
case "#LAC#":
if (!data[i].isEmpty()) {
@@ -215,11 +239,16 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
position.set("destination", data[i]);
break;
case "#IGN#":
+ case "#IGNL#":
position.set(Position.KEY_IGNITION, data[i].equals("1"));
break;
case "#ENG#":
position.set("engine", data[i].equals("1"));
break;
+ case "#DUR#":
+ case "#TDUR#":
+ position.set(Position.KEY_HOURS, Integer.parseInt(data[i]));
+ break;
case "#SATU#":
position.set(Position.KEY_SATELLITES, Integer.parseInt(data[i]));
break;
diff --git a/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java
index 1dd96d8ca..c15e9e48a 100644
--- a/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java
@@ -11,6 +11,11 @@ public class StarLinkProtocolDecoderTest extends ProtocolTest {
StarLinkProtocolDecoder decoder = new StarLinkProtocolDecoder(null);
+ decoder.setFormat("#IMEI#,#EDT#,#EDSC#,#EID#,#PDT#,#LAT#,#LONG#,#SPDK#,#IGNL#,#HEAD#,#ODO#,#DUR#,#TDUR#,#VIN#,#VBAT#,#BATC#,#SATU#,#CSS#,#IN2#,#TVI#,#OUT1#,#OUT2#,#OUT3#,#OUTC#");
+
+ verifyAttributes(decoder, text(
+ "$SLU862549048423605,06,22597,862549048423605,201102121748,Location,01,201102121744,+4133.1223,+00205.8716,54,1,174,007572,2,7712,13.094,00.039,,11,75,1,29.0,0,0,0,0,1,4*6D"));
+
decoder.setFormat("#IMEI#,#EDT#,#PDT#,#LAT#,#LONG#,#SPD#,#IGN#,#ODO#,#DUR#,#TDUR#,#LAC#,#CID#,#VIN#,#VBAT#,#EID#,#EDSC#,#DRV#,#SATU#,#CSS#,#OUT1#,#OUT2#,#IN2#,#IND#");
verifyAttribute(decoder, text(