diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-08-30 22:12:13 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-08-30 22:12:13 -0700 |
commit | 9411263d59a053347cae7feb47248b8b8d0c2d62 (patch) | |
tree | 40ab9e35b1660baa2bcba629ffe4a2eb71fe538a | |
parent | c08d8c971390446ad20f04e67c7e63c7fe1d767d (diff) | |
download | trackermap-server-9411263d59a053347cae7feb47248b8b8d0c2d62.tar.gz trackermap-server-9411263d59a053347cae7feb47248b8b8d0c2d62.tar.bz2 trackermap-server-9411263d59a053347cae7feb47248b8b8d0c2d62.zip |
Support GL501M protocol
-rw-r--r-- | src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 19 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 194a21bf7..cd5b41c39 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -190,6 +190,12 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .expression(PATTERN_LOCATION.pattern()) .expression(")+)") .groupBegin() + .number("d{1,2},,") + .number("(d{1,3}),") // battery + .number("[01],") // mode + .number("[01],") // motion + .number("(?:-?d{1,2}.d)?,") // temperature + .or() .number("(d{1,7}.d)?,") // odometer .number("(d{5}:dd:dd)?,") // hour meter .number("(x+)?,") // adc 1 @@ -214,6 +220,15 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .text("$").optional() .compile(); + /* + CSQ BER <=2 0 - 7|99 +Reserved 0 +Battery Percentage <=3 0 - 100 +Mode Selection 1 0|1 +Movement Status 1 0|1 +Temperature <=5 (-)XX.X + */ + private static final Pattern PATTERN_ERI = new PatternBuilder() .text("+").expression("(?:RESP|BUFF):GTERI,") .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version @@ -841,6 +856,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } if (parser.hasNext()) { + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); + } + + if (parser.hasNext()) { position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); } position.set(Position.KEY_HOURS, parseHours(parser.next())); diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index d107387f4..188d4f40f 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -12,6 +12,10 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(null); verifyAttribute(decoder, buffer( + "+RESP:GTFRI,DE0114,865284041308986,,0,0,1,0,0.0,0,245.6,-117.678624,34.032081,20200825030332,0311,0480,3304,00C7F601,24,0,,85,1,1,,20200825030738,03B1$"), + Position.KEY_BATTERY_LEVEL, 85); + + verifyAttribute(decoder, buffer( "+RESP:GTFRI,380903,869606020188383,,,40,1,2,43.4,80,252.4,8.606297,50.700200,20200721090109,0262,0001,1932,1BA4,00,0.0,,,,0,220100,,,,20200721090110,00B9$"), Position.PREFIX_IN + 1, false); |