aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java24
-rw-r--r--test/org/traccar/protocol/XexunProtocolDecoderTest.java6
2 files changed, 23 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index fb8107d3a..20804bbb4 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2017 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.
@@ -66,16 +66,25 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
- private String decodeAlarm(String value) {
+ private String decodeStatus(Position position, String value) {
if (value != null) {
- switch (value) {
+ switch (value.toLowerCase()) {
+ case "acc on":
+ position.set(Position.KEY_IGNITION, true);
+ break;
+ case "acc off":
+ position.set(Position.KEY_IGNITION, false);
+ break;
case "help me!":
- return Position.ALARM_SOS;
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ break;
case "low battery":
- return Position.ALARM_LOW_BATTERY;
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
case "move!":
case "moved!":
- return Position.ALARM_MOVEMENT;
+ position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT);
+ break;
default:
break;
}
@@ -127,7 +136,8 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
position.set("signal", parser.next());
- position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
+
+ decodeStatus(position, parser.next());
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
index c1e160192..686d3f53f 100644
--- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
@@ -54,6 +54,12 @@ public class XexunProtocolDecoderTest extends ProtocolTest {
"GPRMC,043435.000,A,811.299200,S,11339.9500,E,0.93,29.52,160313,00,0000.0,A*65,F,,imei:359585014597923,"));
decoder = new XexunProtocolDecoder(new XexunProtocol(), true);
+
+ verifyPosition(decoder, text(
+ "170505103845,TELKOMSEL,GPRMC,103845.000,A,0340.2482,N,09841.9689,E,0.00,68.23,050517,,,A*5D,F,ACC On, imei:013227002782161,05,-8.2,F:4.22V,1,141,44712,510,10,2BE5,EC47"));
+
+ verifyPosition(decoder, text(
+ "170607031932,+6282167979090,GPRMC,031932.000,A,0347.2515,N,09841.9433,E,0.00,261.22,070617,,,A*6C,F,ACC OFF, imei:013226004613135,11,23.1,F:4.25V,1,148,44989,510,10,2B34,0268"));
verifyNull(decoder, text(
",+48606717068,,L,, imei:012207005047292,,,F:4.28V,1,52,11565,247,01,000E,1FC5"));