aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-16 17:46:25 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-16 17:46:25 -0700
commitdcdbbf298e91e04c36c0310ac9c3314000d8781f (patch)
tree21363d1fd5a51344369cf285cd1e707c65623dab /src
parent823795e40bf9b029a5c6c80fe58744244d24a5c7 (diff)
downloadtrackermap-server-dcdbbf298e91e04c36c0310ac9c3314000d8781f.tar.gz
trackermap-server-dcdbbf298e91e04c36c0310ac9c3314000d8781f.tar.bz2
trackermap-server-dcdbbf298e91e04c36c0310ac9c3314000d8781f.zip
Support Farnear alarms
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/GotopProtocolDecoder.java19
-rw-r--r--src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java14
2 files changed, 28 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java b/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java
index a867451aa..0f8d29228 100644
--- a/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.number("(d+),") // imei
- .expression("[^,]+,") // type
+ .expression("([^,]+),") // type
.expression("([AV]),") // validity
.number("DATE:(dd)(dd)(dd),") // date (yyddmm)
.number("TIME:(dd)(dd)(dd),") // time (hhmmss)
@@ -56,14 +56,25 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position(getProtocolName());
-
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
}
+
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ String type = parser.next();
+ if (type.equals("CMD-KEY")) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ } else if (type.startsWith("ALM-B")) {
+ if (Character.getNumericValue(type.charAt(5)) % 2 > 0) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_ENTER);
+ } else {
+ position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT);
+ }
+ }
+
position.setValid(parser.next().equals("A"));
position.setTime(parser.nextDateTime());
diff --git a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java
index bae187959..373858c79 100644
--- a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java
@@ -2,6 +2,7 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import org.traccar.model.Position;
public class GotopProtocolDecoderTest extends ProtocolTest {
@@ -12,7 +13,18 @@ public class GotopProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, text(
""));
-
+
+ verifyAttribute(decoder, text(
+ "867688033841044,ALM-B1-1,A,DATE:190622,TIME:144956,LAT:22.7193976N,LON:114.3878200E,Speed:000.1,100-22,03.72"),
+ Position.KEY_ALARM, Position.ALARM_GEOFENCE_ENTER);
+
+ verifyAttribute(decoder, text(
+ "860264050778076,CMD-KEY,V,DATE:220516,TIME:090224,LAT:48.7592616N,LON:003.4658121W,Speed:000.0,057-21,01.60"),
+ Position.KEY_ALARM, Position.ALARM_SOS);
+
+ verifyPosition(decoder, text(
+ "860264050778076,CMD-T,A,DATE:220516,TIME:100627,LAT:48.7636978N,LON:003.4652398W,Speed:051.4,077-24,01.00,WIFI:{84-a0-6e-94-42-5e&-47,b2-22-7a-56-5a-2a&-48,b4-b0-24-09-91-d4&-76,18-3c-b7-1f-da-67&-83,08-86-3b-94-78-44&-85,40-24-b2-c5-0f-5e&-87,b0-e5-ed-4e-06-61&-87,60-1d-9d-a6-d2-5d&-88,14-eb-b6-a5-55-8c&-88,40-18-b1-d7-28-54&-88},BLE:{1f-cf-4d-3c-61-bf&-91,39-82-d0-ba-34-69&-57,df-3a-31-ac-ad-72&-73,7c-d9-f4-11-0b-a0&-78,03-b5-9f-45-bd-0d&-88}"));
+
verifyNull(decoder, text(
"353327020412763,CMD-X"));