aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorHans van den Elsen <hans.elsen@esds.nl>2016-02-13 16:13:35 +0100
committerHans van den Elsen <hans.elsen@esds.nl>2016-02-13 16:13:35 +0100
commit54f8bba338b7262ad6c938bb2284c148fee6cd62 (patch)
treed87961aa0c060f461d17f9ac00b8122eb34be22b /src/org/traccar/protocol
parent8622ba6e081b987a96e3b1885209576f3c389266 (diff)
parent9b11013c2376ad0401c194d5cfa0014e0a08502e (diff)
downloadtraccar-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.tar.gz
traccar-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.tar.bz2
traccar-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.zip
Merge branch 'master' of https://github.com/tananaev/traccar
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java41
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java48
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocol.java2
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java5
8 files changed, 96 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index 2f0d692e9..72a17eed2 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -131,7 +131,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // engine load
break;
case "TR":
- buf.readUnsignedByte(); // throttle position
+ position.set(Event.KEY_THROTTLE, buf.readUnsignedByte());
break;
case "ET":
buf.readUnsignedShort(); // engine coolant temp
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index e36d086f8..3179cbd78 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -115,9 +115,14 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
- buf.skipBytes(2); // header
+ int header = buf.readUnsignedShort();
buf.readUnsignedShort(); // length
- int version = buf.readUnsignedByte();
+
+ int version = -1;
+ if (header == 0x4040) {
+ version = buf.readUnsignedByte();
+ }
+
ChannelBuffer id = buf.readBytes(20);
int type = ChannelBuffers.swapShort(buf.readShort());
@@ -125,7 +130,37 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- if (version == 4) {
+ if (version == -1) {
+
+ if (type == 0x2001) {
+
+ if (channel != null) {
+ int length = 2 + 2 + id.readableBytes() + 2 + 4 + 8 + 2 + 2;
+
+ ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
+ response.writeByte('@'); response.writeByte('@');
+ response.writeShort(length);
+ response.writeBytes(id);
+ response.writeShort(ChannelBuffers.swapShort((short) 0x1001));
+ response.writeInt(0);
+ for (int i = 0; i < 8; i++) {
+ response.writeByte(0xff);
+ }
+ response.writeShort(
+ Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
+ response.writeByte(0x0D); response.writeByte(0x0A);
+ channel.write(response, remoteAddress);
+ }
+
+ buf.readUnsignedInt(); // index
+ buf.readUnsignedInt(); // unix time
+ buf.readUnsignedByte();
+
+ return readPosition(buf);
+
+ }
+
+ } else if (version == 4) {
if (type == MSG_SC_HEARTBEAT) {
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index a2681e10d..e4bf43979 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -203,7 +203,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set("odb-connect", parser.next());
position.set("dtcs-number", parser.next());
position.set("dtcs-codes", parser.next());
- position.set("throttle-position", parser.next());
+ position.set(Event.KEY_THROTTLE, parser.next());
position.set(Event.KEY_FUEL, parser.next());
position.set(Event.KEY_OBD_ODOMETER, parser.next());
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 2c7397231..a45e20ba2 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2016 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.
@@ -78,6 +78,27 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
.number("##,imei:(d+),A")
.compile();
+ private static final Pattern PATTERN_OBD = new PatternBuilder()
+ .text("imei:")
+ .number("(d+),") // imei
+ .expression("OBD,") // type
+ .number("(dd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
+ .number("(d+),") // odometer
+ .number("(d+.d+)?,") // fuel instant
+ .number("(?:d+.d+)?,") // fuel average
+ .number("(d+),") // speed
+ .number("d+,") // power load
+ .number("(d+.d+%),") // throttle
+ .number("(d+),") // rpm
+ .number("(d+.d+%),") // battery
+ .number("[^,]*,") // dtc 1
+ .number("[^,]*,") // dtc 2
+ .number("[^,]*,") // dtc 3
+ .number("[^,]*") // dtc 4
+ .any()
+ .compile();
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -124,6 +145,31 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
}
+ parser = new Parser(PATTERN_OBD, sentence);
+ if (parser.matches()) {
+
+ if (!identify(parser.next(), channel, remoteAddress)) {
+ return null;
+ }
+ position.setDeviceId(getDeviceId());
+
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+
+ getLastLocation(position, dateBuilder.getDate());
+
+ position.set(Event.KEY_ODOMETER, parser.nextInt());
+ position.set(Event.KEY_FUEL, parser.next());
+ position.set(Event.KEY_OBD_SPEED, parser.next());
+ position.set(Event.KEY_THROTTLE, parser.next());
+ position.set(Event.KEY_RPM, parser.next());
+ position.set(Event.KEY_BATTERY, parser.next());
+
+ return position;
+
+ }
+
parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
diff --git a/src/org/traccar/protocol/Tlt2hProtocol.java b/src/org/traccar/protocol/Tlt2hProtocol.java
index d1a8ee735..3a1bf99ff 100644
--- a/src/org/traccar/protocol/Tlt2hProtocol.java
+++ b/src/org/traccar/protocol/Tlt2hProtocol.java
@@ -36,7 +36,7 @@ public class Tlt2hProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##"));
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##\r\n"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new Tlt2hProtocolDecoder(Tlt2hProtocol.this));
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index 5f44bd989..802b00f1f 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -35,7 +35,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN_HEADER = new PatternBuilder()
.number("#(d+)#") // imei
- .expression("[^#]+#")
+ .expression("[^#]*#")
.number("d+#")
.expression("([^#]+)#") // status
.number("d+") // number of records
@@ -50,8 +50,8 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
.expression("([NS]),")
.number("(d+)(dd.d+),") // longitude
.number("([EW]),")
- .number("(d+.d+)?,") // speed
- .number("(d+.d+)?,") // course
+ .number("(d+.?d*)?,") // speed
+ .number("(d+.?d*)?,") // course
.number("(dd)(dd)(dd)") // date (ddmmyy)
.any()
.compile();
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index 62cdd230c..94796fa5e 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -44,7 +44,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
.expression("([EW])")
.number("(ddd.d)") // speed
.number("(dd)(dd)(dd)") // time
- .number("(ddd.dd)") // course
+ .number("([d.]{6})") // course
.number("(ddd)") // gsm
.number("(ddd)") // satellites
.number("(ddd)") // battery
@@ -78,7 +78,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
String type = sentence.substring(3, 7);
if (channel != null) {
- channel.write((char) (type.charAt(0) + 1) + type.substring(1)); // response
+ channel.write("TRV" + (char) (type.charAt(0) + 1) + type.substring(1) + "#"); // response
}
if (type.equals("AP00")) {
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index f9369b463..0929ee99b 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -44,8 +44,9 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*)?,") // course
.number("(dd)(dd)(dd),") // date
.expression("[^*]*").text("*")
- .number("xx,") // checksum
- .expression("([FL]),") // signal
+ .number("xx") // checksum
+ .expression("\\r\\n").optional()
+ .expression(",([FL]),") // signal
.expression("([^,]*),").optional() // alarm
.any()
.number("imei:(d+),") // imei