diff options
author | jcardus <asklocation.net@gmail.com> | 2024-03-29 01:10:06 +0000 |
---|---|---|
committer | jcardus <asklocation.net@gmail.com> | 2024-03-29 01:10:06 +0000 |
commit | 0bf22eb231e3eb9ecf912f41dcc8f5e7f7fa8865 (patch) | |
tree | 9c794c571287132152e760f2f443ee92b0f4dd22 /src | |
parent | b6be94fef718926f5575257ab2724f5e538e215f (diff) | |
download | trackermap-server-0bf22eb231e3eb9ecf912f41dcc8f5e7f7fa8865.tar.gz trackermap-server-0bf22eb231e3eb9ecf912f41dcc8f5e7f7fa8865.tar.bz2 trackermap-server-0bf22eb231e3eb9ecf912f41dcc8f5e7f7fa8865.zip |
Fix INF message on GV310LAU
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 28 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 11 |
2 files changed, 33 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 7a8d67cf9..b998f718e 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -122,12 +122,12 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_INF = new PatternBuilder() .text("+").expression("(?:RESP|BUFF):GTINF,") - .expression("(?:.{6}|.{10})?,") // protocol version + .expression("(.{6}|.{10})?,") // protocol version .number("(d{15}|x{14}),") // imei .expression("(?:[0-9A-Z]{17},)?") // vin .expression("(?:[^,]+)?,") // device name .number("(xx),") // state - .expression("(?:[0-9Ff]{20})?,") // iccid + .expression("([0-9Ff]{20})?,") // iccid .number("(d{1,2}),") // rssi .number("d{1,2},") .expression("[01]{1,2},") // external power @@ -148,6 +148,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .expression("(?:[01])?,").optional() // pin15 mode .number("(d+)?,") // adc1 .number("(d+)?,").optional() // adc2 + .number("(d+)?,").optional() // adc3 .number("(xx)?,") // digital input .number("(xx)?,") // digital output .number("[-+]dddd,") // timezone @@ -163,10 +164,17 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeInf(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_INF, sentence); - Position position = initPosition(parser, channel, remoteAddress); - if (position == null) { + if (!parser.matches()) { return null; } + String protocolVersion = parser.next(); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); switch (parser.nextHexInt()) { case 0x16: @@ -197,9 +205,14 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { break; } + position.set(Position.KEY_ICCID, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); - - parser.next(); // odometer or external power + + if (protocolVersion.startsWith("6E")) { // GV310LAU + position.set(Position.KEY_POWER, parser.nextDouble() / 1000); // odometer or external power + } else { + parser.next(); // odometer or external power + } position.set(Position.KEY_BATTERY, parser.nextDouble()); position.set(Position.KEY_CHARGE, parser.nextInt() == 1); @@ -210,6 +223,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); + if (protocolVersion.startsWith("6E")) { + position.set(Position.PREFIX_ADC + 3, parser.next()); + } position.set(Position.KEY_INPUT, parser.next()); position.set(Position.KEY_OUTPUT, parser.next()); diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index b6e50e07d..768704b68 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -487,6 +487,17 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { verifyAttributes(decoder, buffer( "+ACK:GTGEO,1A0102,135790246811220,,0,0008,20100310172830,11F0")); + verifyAttributes(decoder, buffer( + "+RESP:GTINF,6E0202,868589060187625,RA82,11,89883030000091225018,41,0,1,12349,,4.15,0,1,0,0,20240328231013,0,0,0,0,00,00,+0000,0,20240328231015,7D4F")); + + verifyAttribute(decoder, buffer( + "+RESP:GTINF,6E0202,868589060187625,RA82,11,89883030000091225018,41,0,1,12349,,4.15,0,1,0,0,20240328231013,0,0,0,0,00,00,+0000,0,20240328231015,7D4F"), + Position.KEY_POWER, 12.349); + + verifyAttribute(decoder, buffer( + "+RESP:GTINF,6E0202,868589060187625,RA82,11,89883030000091225018,41,0,1,12349,,4.15,0,1,0,0,20240328231013,0,0,0,0,00,00,+0000,0,20240328231015,7D4F"), + Position.PREFIX_ADC + 3, "0"); + decoder.setModelOverride("GV355CEU"); verifyAttributes(decoder, buffer( |