aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-04 23:14:46 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-02-04 23:14:46 +1300
commit0f6a2399433c65b3b03c1f660e148cd1dd1436a7 (patch)
tree352f3b3dd6f0eb10c4a2946c357d481640aa0d6f
parent526618bcd0be9b879ed8051b2e4e421566454bbc (diff)
downloadtrackermap-server-0f6a2399433c65b3b03c1f660e148cd1dd1436a7.tar.gz
trackermap-server-0f6a2399433c65b3b03c1f660e148cd1dd1436a7.tar.bz2
trackermap-server-0f6a2399433c65b3b03c1f660e148cd1dd1436a7.zip
Extend GPS103 protocol decoder
-rw-r--r--src/org/traccar/model/Position.java4
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java19
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java23
3 files changed, 45 insertions, 1 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 6163227b3..a88e16804 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -93,6 +93,10 @@ public class Position extends Message {
public static final String ALARM_JAMMING = "jamming";
public static final String ALARM_TEMPERATURE = "temperature";
public static final String ALARM_PARKING = "parking";
+ public static final String ALARM_SHOCK = "shock";
+ public static final String ALARM_BONNET = "bonnet";
+ public static final String ALARM_FOOT_BRAKE = "footBrake";
+ public static final String ALARM_OIL_LEAK = "oilLeak";
private String protocol;
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 0320f785f..2f8fe4bba 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -102,6 +102,11 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private String decodeAlarm(String value) {
+ if (value.startsWith("T:")) {
+ return Position.ALARM_TEMPERATURE;
+ } else if (value.startsWith("oil")) {
+ return Position.ALARM_OIL_LEAK;
+ }
switch (value) {
case "tracker":
return null;
@@ -123,6 +128,16 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
return Position.ALARM_DOOR;
case "ac alarm":
return Position.ALARM_POWER_CUT;
+ case "accident alarm":
+ return Position.ALARM_ACCIDENT;
+ case "sensor alarm":
+ return Position.ALARM_SHOCK;
+ case "bonnet alarm":
+ return Position.ALARM_BONNET;
+ case "footbrake alarm":
+ return Position.ALARM_FOOT_BRAKE;
+ case "DTC":
+ return Position.ALARM_FAULT;
default:
return null;
}
@@ -232,6 +247,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, true);
} else if (alarm.equals("acc off")) {
position.set(Position.KEY_IGNITION, false);
+ } else if (alarm.startsWith("T:")) {
+ position.set(Position.PREFIX_TEMP + 1, alarm.substring(2));
+ } else if (alarm.startsWith("oil ")) {
+ position.set("oil", alarm.substring(4));
}
DateBuilder dateBuilder = new DateBuilder()
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index e110de24b..a2f69a8fa 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -10,7 +10,28 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest {
Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol());
- verifyAttributes(decoder, text(
+ verifyPosition(decoder, text(
+ "imei:353451044508750,DTC,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,30.1,,1,0,10.5%,P0021,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,oil1,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,,,51.6,41.7,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,oil2,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,,,51.6,41.7,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,oil 51.67,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,T:+28.0,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,bonnet alarm,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,;"));
+
+ verifyPosition(decoder, text(
+ "imei:353451044508750,footbrake alarm,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,;"));
+
+ verifyPosition(decoder, text(
"imei:862106021237716,ac alarm,1611291645,,F,204457.000,A,1010.2783,N,06441.0274,W,0.00,,;"));
verifyAttributes(decoder, text(