aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-10-05 11:05:58 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-10-05 11:05:58 -0700
commit2e71806e6c6206acffc78f28101688963418aa6c (patch)
treeb0daa06a218f3dcc9638a0c097d13c10dc28cdc0 /src
parent14f5711c4966f8fa38a49a5c9b62c7148ece06de (diff)
downloadtrackermap-server-2e71806e6c6206acffc78f28101688963418aa6c.tar.gz
trackermap-server-2e71806e6c6206acffc78f28101688963418aa6c.tar.bz2
trackermap-server-2e71806e6c6206acffc78f28101688963418aa6c.zip
Decode Falcom Mambo 2 battery info
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/T55ProtocolDecoder.java33
-rw-r--r--src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java5
2 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
index e25f9e11a..b75addfae 100644
--- a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
@@ -96,6 +96,19 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private static final Pattern PATTERN_GPIOP = new PatternBuilder()
+ .text("$GPIOP,")
+ .number("[01]{8},") // inputs
+ .number("[01]{8},") // outputs
+ .number("d+.d+,") // adc 1
+ .number("d+.d+,") // adc 2
+ .number("d+.d+,") // adc 3
+ .number("d+.d+,") // adc 4
+ .number("(d+.d+),") // power
+ .number("(d+.d+)") // battery
+ .any()
+ .compile();
+
private Position position = null;
private Position decodeGprmc(
@@ -225,6 +238,24 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeGpiop(DeviceSession deviceSession, String sentence) {
+
+ Parser parser = new Parser(PATTERN_GPIOP, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+
+ return position;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -275,6 +306,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return decodeGprma(deviceSession, sentence);
} else if (sentence.startsWith("$TRCCR") && deviceSession != null) {
return decodeTrccr(deviceSession, sentence);
+ } else if (sentence.startsWith("$GPIOP")) {
+ return decodeGpiop(deviceSession, sentence);
}
return null;
diff --git a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
index f21acdee7..c0511f2a1 100644
--- a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
@@ -2,6 +2,7 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import org.traccar.model.Position;
public class T55ProtocolDecoderTest extends ProtocolTest {
@@ -13,6 +14,10 @@ public class T55ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, text(
"$DEVID,0x0103846677F21422*41"));
+ verifyAttribute(decoder, text(
+ "$GPIOP,01000000,00000000,0.00,0.00,0.00,0.00,4.69,4.24*49"),
+ Position.KEY_BATTERY, 4.24);
+
verifyPosition(decoder, text(
"660420156A0066AA$GPRMC,122806.0,A,0119.212178,N,10355.000942,E,0.0,,230119,0.0,E,A*27"));