diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-05 22:44:47 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-05 22:44:47 -0700 |
commit | 12341a04c3c3bd0fe9b0d5d832ee6702bdbd7e18 (patch) | |
tree | 0d2b998d89eef34f7d29c4884a5e61b8d4fd136b /src | |
parent | b5e9d84cfeb8d4e6a4e1133a2e0510652be1de6b (diff) | |
download | trackermap-server-12341a04c3c3bd0fe9b0d5d832ee6702bdbd7e18.tar.gz trackermap-server-12341a04c3c3bd0fe9b0d5d832ee6702bdbd7e18.tar.bz2 trackermap-server-12341a04c3c3bd0fe9b0d5d832ee6702bdbd7e18.zip |
Support Micron protocol
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 13 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 6596d8764..283dbeb37 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -119,9 +119,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .compile(); private static final Pattern PATTERN_LOCATION = new PatternBuilder() - .number("(d{1,2})?,") // hdop + .number("(d{1,2}.?d?)?,") // hdop .number("(d{1,3}.d)?,") // speed - .number("(d{1,3})?,") // course + .number("(d{1,3}.?d?)?,") // course .number("(-?d{1,5}.d)?,") // altitude .number("(-?d{1,3}.d{6})?,") // longitude .number("(-?d{1,2}.d{6})?,") // latitude @@ -184,7 +184,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .number("(d+)?,") // power .number("d{1,2},").optional() // report type .number("d{1,2},").optional() // count - .number(",").optional() // reserved + .number("d*,").optional() // reserved .number("(d+),").optional() // battery .expression("((?:") .expression(PATTERN_LOCATION.pattern()) @@ -202,6 +202,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .or() .number("(d{1,7}.d)?,").optional() // odometer .number("(d{1,3})?,") // battery + .or() + .number("(-?d),") // rssi + .number("(d{1,3}),") // battery .groupEnd() .any() .number("(dddd)(dd)(dd)") // date (yyyymmdd) @@ -514,7 +517,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } private void decodeLocation(Position position, Parser parser) { - Integer hdop = parser.nextInt(); + Double hdop = parser.nextDouble(); position.setValid(hdop == null || hdop > 0); position.set(Position.KEY_HDOP, hdop); @@ -848,6 +851,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); } position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); + position.set(Position.KEY_RSSI, parser.nextInt()); + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); decodeDeviceTime(position, parser); if (ignoreFixTime) { diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index 3e5de0854..12e64cd6d 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(null); + verifyPositions(decoder, buffer( + "+RESP:GTFRI,423031,355154083021002,Bolt4G,0,0,0,0,1,1.0,0.2,0,245.3,-85.630193,42.975280,20190729185934,310,410,500b,B0E320F,31,-1,100,20190729185934,0010$")); + verifyAttribute(decoder, buffer( "+RESP:GTCTN,440200,866427030007379,NOKIA3,0,0,2,,9,1,0.1,174,48.7,-1.061812,51.435270,20190717080549,0234,0015,0025,145A,,,0000,20190717081008,1D3B$"), Position.KEY_BATTERY_LEVEL, 9); |