From e1be8916132fd0102cfe298a75abcfdcd43f244b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 20 Jul 2024 17:37:32 -0700 Subject: Support Jimi IoT extended heartbeat --- .../java/org/traccar/protocol/Gt06ProtocolDecoder.java | 16 ++++++++++++++++ .../org/traccar/protocol/Gt06ProtocolDecoderTest.java | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index f17671cd7..e25499190 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -88,6 +88,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_X1_GPS = 0x34; public static final int MSG_X1_PHOTO_INFO = 0x35; public static final int MSG_X1_PHOTO_DATA = 0x36; + public static final int MSG_STATUS_2 = 0x36; // Jimi IoT 4G public static final int MSG_WIFI_2 = 0x69; public static final int MSG_GPS_MODULAR = 0x70; public static final int MSG_WIFI_4 = 0xF3; @@ -218,6 +219,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private static boolean hasStatus(int type) { switch (type) { case MSG_STATUS: + case MSG_STATUS_2: case MSG_LBS_STATUS: case MSG_GPS_LBS_STATUS_1: case MSG_GPS_LBS_STATUS_2: @@ -845,6 +847,20 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } } + if (type == MSG_STATUS_2) { + buf.readUnsignedByte(); // language + while (buf.readableBytes() > 6) { + int moduleType = buf.readUnsignedShort(); + int moduleLength = buf.readUnsignedByte(); + switch (moduleType) { + case 0x0018 -> position.set(Position.KEY_BATTERY, buf.readUnsignedShort() / 100.0); + case 0x0032 -> position.set("startupStatus", buf.readUnsignedByte()); + case 0x006A -> position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + default -> buf.skipBytes(moduleLength); + } + } + } + if (type == MSG_GPS_LBS_STATUS_5) { buf.readUnsignedByte(); // language position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index da070e224..bb809529a 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -17,6 +17,10 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyAttribute(decoder, binary( + "787817360005040002003201010018020192006a015f0324aeaf0d0a"), + Position.KEY_BATTERY, 4.02); + verifyPosition(decoder, binary( "787840a218061b0e0f05cf021d22430aa2660b005c00014e140000026500000000024d4e02114504df06031c010007d00000000000086973105524576500c802a86fda0d0a")); -- cgit v1.2.3