aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/BoxProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/XexunFrameDecoder.java8
3 files changed, 17 insertions, 17 deletions
diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java
index ffc9f9bd0..2230b1356 100644
--- a/src/org/traccar/protocol/BoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/BoxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2014 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
"(-?\\d+\\.\\d+)," + // Longitude
"(\\d+\\.?\\d*)," + // Speed
"(\\d+\\.?\\d*)," + // Course
- "(\\d+)," + // Distance
+ "(\\d+\\.?\\d*)," + // Distance
"(\\d+)," + // Event
"(\\d+)" + // Status
".*");
@@ -62,7 +62,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
identify(id, channel);
}
- else if (sentence.startsWith("L,")) {
+ else if (hasDeviceId() && sentence.startsWith("L,")) {
// Parse message
Matcher parser = pattern.matcher(sentence);
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index ba6a3e62d..c0288a8d5 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -15,6 +15,12 @@
*/
package org.traccar.protocol;
+import java.net.SocketAddress;
+import java.nio.charset.Charset;
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
@@ -23,13 +29,6 @@ import org.traccar.helper.Crc;
import org.traccar.model.Event;
import org.traccar.model.Position;
-import java.net.SocketAddress;
-import java.nio.charset.Charset;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
public CityeasyProtocolDecoder(CityeasyProtocol protocol) {
@@ -66,9 +65,10 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
String imei = ChannelBufferTools.readHexString(buf, 14);
- imei += Crc.luhnChecksum(Long.valueOf(imei));
- if (!identify(imei, channel)) {
- return null;
+ if (!identify(imei, channel, null, false)) {
+ if (!identify(imei + Crc.luhnChecksum(Long.valueOf(imei)), channel)) {
+ return null;
+ }
}
int type = buf.readUnsignedShort();
diff --git a/src/org/traccar/protocol/XexunFrameDecoder.java b/src/org/traccar/protocol/XexunFrameDecoder.java
index 1b3446ff9..60fa02696 100644
--- a/src/org/traccar/protocol/XexunFrameDecoder.java
+++ b/src/org/traccar/protocol/XexunFrameDecoder.java
@@ -36,22 +36,22 @@ public class XexunFrameDecoder extends FrameDecoder {
}
// Find start
- Integer beginIndex = ChannelBufferTools.find(buf, 0, length, "GPRMC");
+ Integer beginIndex = ChannelBufferTools.find(buf, buf.readerIndex(), "GPRMC");
if (beginIndex == null) {
- beginIndex = ChannelBufferTools.find(buf, 0, length, "GNRMC");
+ beginIndex = ChannelBufferTools.find(buf, buf.readerIndex(), "GNRMC");
if (beginIndex == null) {
return null;
}
}
// Find identifier
- Integer idIndex = ChannelBufferTools.find(buf, beginIndex, length, "imei:");
+ Integer idIndex = ChannelBufferTools.find(buf, beginIndex, "imei:");
if (idIndex == null) {
return null;
}
// Find end
- Integer endIndex = ChannelBufferTools.find(buf, idIndex, length, ",");
+ Integer endIndex = ChannelBufferTools.find(buf, idIndex, ",");
if (endIndex == null) {
return null;
}