From ce1a5a24bbf0a74335cab0799c2d0acdcdde761c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 21 Apr 2017 00:31:53 +1200 Subject: Support newer Wialon protocol versions --- src/org/traccar/protocol/WialonProtocolDecoder.java | 6 ++++-- test/org/traccar/protocol/WialonProtocolDecoderTest.java | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index a07dfc7c9..90b7e7847 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2014 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2017 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. @@ -136,7 +136,9 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { if (sentence.startsWith("#L#")) { - String imei = sentence.substring(3, sentence.indexOf(';')); + String[] values = sentence.substring(3).split(";"); + + String imei = values[0].indexOf('.') >= 0 ? values[1] : values[0]; DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); if (deviceSession != null) { sendResponse(channel, "#AL#", 1); diff --git a/test/org/traccar/protocol/WialonProtocolDecoderTest.java b/test/org/traccar/protocol/WialonProtocolDecoderTest.java index 4e73c7d49..881b39cf7 100644 --- a/test/org/traccar/protocol/WialonProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WialonProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class WialonProtocolDecoderTest extends ProtocolTest { WialonProtocolDecoder decoder = new WialonProtocolDecoder(new WialonProtocol()); + verifyNull(decoder, text( + "#L#2.0;42001300083;;CE45")); + verifyNull(decoder, text( "#L#123456789012345;test")); -- cgit v1.2.3