From 94d95ebeb1168ff235aa49a24c0ba0ed62b1125b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 30 Jun 2021 22:17:02 -0700 Subject: Ignore keepalive messages --- src/main/java/org/traccar/protocol/UuxProtocolDecoder.java | 5 +++++ src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java | 3 +++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/UuxProtocolDecoder.java b/src/main/java/org/traccar/protocol/UuxProtocolDecoder.java index 545784865..1081fa811 100644 --- a/src/main/java/org/traccar/protocol/UuxProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/UuxProtocolDecoder.java @@ -40,6 +40,7 @@ public class UuxProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_IMMOBILIZER = 0x9E; public static final int MSG_ACK = 0xD0; public static final int MSG_NACK = 0xF0; + public static final int MSG_KEEPALIVE = 0xFF; private void sendResponse(Channel channel, int productCode, int protocolVersion, int type) { if (channel != null && BitUtil.check(protocolVersion, 7)) { @@ -71,6 +72,10 @@ public class UuxProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // length int type = buf.readUnsignedByte(); + if (type == MSG_KEEPALIVE) { + return null; + } + String vehicleId = buf.readCharSequence(10, StandardCharsets.US_ASCII).toString(); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, vehicleId); if (deviceSession == null) { diff --git a/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java index c1acfd740..753063d26 100644 --- a/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class UuxProtocolDecoderTest extends ProtocolTest { var decoder = new UuxProtocolDecoder(null); + verifyNull(decoder, binary( + "81910b01ff")); + verifyAttributes(decoder, binary( "81910c5a9031395533443630363631051e061a1e07397079712a000000000000413133333135332e333939304e30333531322e393837324530303031303030303000000200000000001f303036323236303030303030303030300000ffff")); -- cgit v1.2.3