aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/helper/Parser.java5
-rw-r--r--src/main/java/org/traccar/protocol/EnvotechProtocolDecoder.java21
-rw-r--r--src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java3
3 files changed, 23 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/helper/Parser.java b/src/main/java/org/traccar/helper/Parser.java
index 75106e2ba..22e98ded1 100644
--- a/src/main/java/org/traccar/helper/Parser.java
+++ b/src/main/java/org/traccar/helper/Parser.java
@@ -155,6 +155,7 @@ public class Parser {
public enum CoordinateFormat {
DEG_DEG,
+ DEG_DEG_HEM,
DEG_HEM,
DEG_MIN_MIN,
DEG_MIN_HEM,
@@ -173,6 +174,10 @@ public class Parser {
case DEG_DEG:
coordinate = Double.parseDouble(next() + '.' + next());
break;
+ case DEG_DEG_HEM:
+ coordinate = Double.parseDouble(next() + '.' + next());
+ hemisphere = next();
+ break;
case DEG_HEM:
coordinate = nextDouble(0);
hemisphere = next();
diff --git a/src/main/java/org/traccar/protocol/EnvotechProtocolDecoder.java b/src/main/java/org/traccar/protocol/EnvotechProtocolDecoder.java
index 083d8a921..51391d4cc 100644
--- a/src/main/java/org/traccar/protocol/EnvotechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/EnvotechProtocolDecoder.java
@@ -54,8 +54,8 @@ public class EnvotechProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)(dd)(dd)") // date (ddmmyy)
.number("(dd)(dd)(dd)") // time (hhmmss)
.number("(d)") // fix
- .number("(dd)(dd)(d+)([NS])") // latitude
- .number("(ddd)(dd)(d+)([EW])") // longitude
+ .number("(d+)(d{5})([NS])") // latitude
+ .number("(d+)(d{5})([EW])") // longitude
.number("(ddd)") // speed
.number("(ddd)") // course
.any()
@@ -72,7 +72,18 @@ public class EnvotechProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
- position.set(Position.KEY_EVENT, parser.nextHexInt());
+ int event = parser.nextHexInt();
+ switch (event) {
+ case 0x60:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOCK);
+ break;
+ case 0x61:
+ position.set(Position.KEY_ALARM, Position.ALARM_UNLOCK);
+ break;
+ default:
+ break;
+ }
+ position.set(Position.KEY_EVENT, event);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
@@ -92,8 +103,8 @@ public class EnvotechProtocolDecoder extends BaseProtocolDecoder {
position.setFixTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.setValid(parser.nextInt() > 0);
- position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
- position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG_HEM));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG_HEM));
position.setSpeed(parser.nextInt());
position.setCourse(parser.nextInt());
diff --git a/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java
index 6a455975d..60c592e1e 100644
--- a/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java
@@ -11,7 +11,8 @@ public class EnvotechProtocolDecoderTest extends ProtocolTest {
var decoder = new EnvotechProtocolDecoder(null);
verifyPosition(decoder, text(
- "$80SLM,02,F,AB0010,130410155921,431750216,000040,0000,,00000000,'13041015592110476673N10111459E001281*2A"));
+ "$80SLM,02,F,AB0010,130410155921,431750216,000040,0000,,00000000,'13041015592110476673N10111459E001281*2A"),
+ position("2010-04-13 15:59:21.000", true, 4.76673, 101.11459));
verifyPosition(decoder, text(
"$80SLM,82,F,AB0010,130410155921,431750216,000040,0000,,00000000,'13041015592110476673N10111459E001281@B0,F,C456,038,00,M234567,,,1A2A3A4A5A6A*4E"));