diff options
4 files changed, 44 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java b/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java index 5c8d0bac2..933e6fe4f 100644 --- a/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/GotopProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2024 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. @@ -37,10 +37,14 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // imei .expression("([^,]+),") // type .expression("([AV]),") // validity - .number("DATE:(dd)(dd)(dd),") // date (yyddmm) - .number("TIME:(dd)(dd)(dd),") // time (hhmmss) - .number("LAT:(d+.d+)([NS]),") // latitude - .number("LO[NT]:(d+.d+)([EW]),") // longitude + .text("DATE:").optional() + .number("(dd)(dd)(dd),") // date (yyddmm) + .text("TIME:").optional() + .number("(dd)(dd)(dd),") // time (hhmmss) + .text("LAT:").optional() + .number("(d+.d+)([NS]),") // latitude + .expression("LO[NT]:").optional() + .number("(d+.d+)([EW]),") // longitude .text("Speed:").number("(d+.d+),") // speed .expression("([^,]+),") // status .number("(d+)?") // course diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index eb8ba2375..372cf5f78 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -101,6 +101,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_GPS_LBS_7 = 0xA0; // GK310 & JM-VL03 public static final int MSG_LBS_2 = 0xA1; // GK310 public static final int MSG_WIFI_3 = 0xA2; // GK310 + public static final int MSG_GPS_LBS_STATUS_5 = 0xA2; // LWxG public static final int MSG_FENCE_SINGLE = 0xA3; // GK310 public static final int MSG_FENCE_MULTI = 0xA4; // GK310 & JM-LL301 public static final int MSG_LBS_ALARM = 0xA5; // GK310 & JM-LL301 @@ -127,6 +128,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { SL4X, SEEWORLD, RFID, + LW4G, } private Variant variant; @@ -174,6 +176,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { case MSG_GPS_LBS_STATUS_2: case MSG_GPS_LBS_STATUS_3: case MSG_GPS_LBS_STATUS_4: + case MSG_GPS_LBS_STATUS_5: case MSG_GPS_PHONE: case MSG_GPS_LBS_EXTEND: case MSG_GPS_LBS_7: @@ -199,6 +202,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { case MSG_GPS_LBS_STATUS_2: case MSG_GPS_LBS_STATUS_3: case MSG_GPS_LBS_STATUS_4: + case MSG_GPS_LBS_STATUS_5: case MSG_GPS_LBS_7: case MSG_GPS_LBS_RFID: case MSG_FENCE_SINGLE: @@ -219,6 +223,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { case MSG_GPS_LBS_STATUS_2: case MSG_GPS_LBS_STATUS_3: case MSG_GPS_LBS_STATUS_4: + case MSG_GPS_LBS_STATUS_5: case MSG_FENCE_MULTI: case MSG_LBS_ALARM: return true; @@ -354,13 +359,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { mnc = buf.readUnsignedByte(); } int lac; - if (type == MSG_LBS_ALARM || type == MSG_GPS_LBS_7) { + if (type == MSG_LBS_ALARM || type == MSG_GPS_LBS_7 || type == MSG_GPS_LBS_STATUS_5) { lac = buf.readInt(); } else { lac = buf.readUnsignedShort(); } long cid; - if (type == MSG_LBS_ALARM || type == MSG_GPS_LBS_7 || variant == Variant.SL4X) { + if (type == MSG_LBS_ALARM || type == MSG_GPS_LBS_7 || variant == Variant.SL4X || type == MSG_GPS_LBS_STATUS_5) { cid = buf.readLong(); } else if (type == MSG_GPS_LBS_6 || variant == Variant.SEEWORLD) { cid = buf.readUnsignedInt(); @@ -690,7 +695,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else if (type == MSG_LBS_MULTIPLE_1 || type == MSG_LBS_MULTIPLE_2 || type == MSG_LBS_MULTIPLE_3 || type == MSG_LBS_EXTEND || type == MSG_LBS_WIFI || type == MSG_LBS_2 || type == MSG_LBS_3 - || type == MSG_WIFI_3 || type == MSG_WIFI_5) { + || (type == MSG_WIFI_3 && variant != Variant.LW4G) || type == MSG_WIFI_5) { DateBuilder dateBuilder = new DateBuilder((TimeZone) deviceSession.get(DeviceSession.KEY_TIMEZONE)) .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) @@ -828,11 +833,15 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { boolean hasLength = hasStatus(type) && type != MSG_LBS_STATUS && type != MSG_LBS_ALARM - && (type != MSG_GPS_LBS_STATUS_1 || variant != Variant.VXT01); + && (type != MSG_GPS_LBS_STATUS_1 || variant != Variant.VXT01) + && type != MSG_GPS_LBS_STATUS_5; decodeLbs(position, buf, type, hasLength); } if (hasStatus(type)) { + if (type == MSG_GPS_LBS_STATUS_5) { + buf.readUnsignedByte(); // network indicator + } decodeStatus(position, buf); if (variant == Variant.OBD6) { int signal = buf.readUnsignedShort(); @@ -846,6 +855,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // working mode position.set(Position.KEY_POWER, buf.readUnsignedShort() / 100.0); } else { + if (type == MSG_GPS_LBS_STATUS_5) { + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + } int battery = buf.readUnsignedByte(); position.set(Position.KEY_BATTERY_LEVEL, battery <= 6 ? battery * 100 / 6 : battery); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); @@ -856,6 +868,14 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } } + if (type == MSG_GPS_LBS_STATUS_5) { + buf.readUnsignedByte(); // language + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_HOURS, buf.readUnsignedInt() * 1000); + buf.skipBytes(8); // terminal id + position.set(Position.KEY_INPUT, buf.readUnsignedShort()); + } + if (type == MSG_GPS_LBS_1) { if (variant == Variant.GT06E_CARD) { position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); @@ -1522,6 +1542,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { variant = Variant.SEEWORLD; } else if (header == 0x7878 && type == MSG_GPS_LBS_RFID && length == 0x28) { variant = Variant.RFID; + } else if (header == 0x7878 && type == MSG_GPS_LBS_STATUS_5 && length == 0x40) { + variant = Variant.LW4G; } else { variant = Variant.STANDARD; } diff --git a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java index aea6e7592..8601618bd 100644 --- a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class GotopProtocolDecoderTest extends ProtocolTest { var decoder = inject(new GotopProtocolDecoder(null)); + verifyPosition(decoder, text( + "012896001901633,CMD-T,A,130104,175950,24.0234233S,029.4691133E,Speed:001.8,90-24,1.3,10,10,65501-0371-170D,12,1-1,00.00")); + + verifyPosition(decoder, text( + "012896001901633,CMD-T,A,130104,175950,24.0234233S,029.4691133E,Speed:001.8,90-24,1.3,00.00")); + verifyNull(decoder, text( "")); diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 9e9d3667d..da070e224 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -17,6 +17,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "787840a218061b0e0f05cf021d22430aa2660b005c00014e140000026500000000024d4e02114504df06031c010007d00000000000086973105524576500c802a86fda0d0a")); + verifyAttribute(decoder, binary( "79790007940B010A0B5ACE0D0A"), "networkTechnology", "4G"); |