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/CarcellProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java102
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/HaicomProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/IdplProtocol.java4
-rw-r--r--src/org/traccar/protocol/IdplProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java40
-rw-r--r--src/org/traccar/protocol/OigoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/PricolProtocol.java7
-rw-r--r--src/org/traccar/protocol/PricolProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Stl060ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TmgProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/TrakMateProtocolDecoder.java2
16 files changed, 120 insertions, 85 deletions
diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java
index 23889a5bd..615115147 100644
--- a/src/org/traccar/protocol/CarcellProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java
@@ -118,7 +118,7 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(1)) {
- position.set("accel", parser.nextInt());
+ position.set(Position.KEY_ACCELERATION, parser.nextInt());
}
Double internalBattery = (parser.nextDouble() + 100d) * 0.0294d;
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index c9aae8e96..a3f99c674 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 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.
@@ -39,24 +39,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private static final int TAG_IMEI = 0x03;
- private static final int TAG_DATE = 0x20;
- private static final int TAG_COORDINATES = 0x30;
- private static final int TAG_SPEED_COURSE = 0x33;
- private static final int TAG_ALTITUDE = 0x34;
- private static final int TAG_STATUS = 0x40;
- private static final int TAG_POWER = 0x41;
- private static final int TAG_BATTERY = 0x42;
- private static final int TAG_ODOMETER = 0xd4;
- private static final int TAG_REFRIGERATOR = 0x5b;
- private static final int TAG_PRESSURE = 0x5c;
- private static final int TAG_CAN = 0xc1;
- private static final int TAG_ADC0 = 0x50;
- private static final int TAG_ADC1 = 0x51;
- private static final int TAG_ADC2 = 0x52;
- private static final int TAG_ADC3 = 0x53;
- private static final int TAG_ARRAY = 0xea;
-
private static final Map<Integer, Integer> TAG_LENGTH_MAP = new HashMap<>();
static {
@@ -96,10 +78,8 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
for (int i : l4) {
TAG_LENGTH_MAP.put(i, 4);
}
- TAG_LENGTH_MAP.put(TAG_COORDINATES, 9);
- TAG_LENGTH_MAP.put(TAG_IMEI, 15);
- TAG_LENGTH_MAP.put(TAG_REFRIGERATOR, 7); // variable length
- TAG_LENGTH_MAP.put(TAG_PRESSURE, 68);
+ TAG_LENGTH_MAP.put(0x5b, 7); // variable length
+ TAG_LENGTH_MAP.put(0x5c, 68);
}
private static int getTagLength(int tag) {
@@ -149,77 +129,87 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
tags.add(tag);
switch (tag) {
-
- case TAG_IMEI:
+ case 0x01:
+ position.set(Position.KEY_VERSION_HW, buf.readUnsignedByte());
+ break;
+ case 0x02:
+ position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
+ break;
+ case 0x03:
getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII));
break;
-
- case TAG_DATE:
+ case 0x04:
+ position.set("deviceId", buf.readUnsignedShort());
+ break;
+ case 0x10:
+ position.set(Position.KEY_INDEX, buf.readUnsignedShort());
+ break;
+ case 0x20:
position.setTime(new Date(buf.readUnsignedInt() * 1000));
break;
-
- case TAG_COORDINATES:
+ case 0x30:
hasLocation = true;
position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00);
position.setLatitude(buf.readInt() / 1000000.0);
position.setLongitude(buf.readInt() / 1000000.0);
break;
-
- case TAG_SPEED_COURSE:
+ case 0x33:
position.setSpeed(buf.readUnsignedShort() * 0.0539957);
position.setCourse(buf.readUnsignedShort() * 0.1);
break;
-
- case TAG_ALTITUDE:
+ case 0x34:
position.setAltitude(buf.readShort());
break;
-
- case TAG_STATUS:
+ case 0x40:
position.set(Position.KEY_STATUS, buf.readUnsignedShort());
break;
-
- case TAG_POWER:
+ case 0x41:
position.set(Position.KEY_POWER, buf.readUnsignedShort());
break;
-
- case TAG_BATTERY:
+ case 0x42:
position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
break;
-
- case TAG_ODOMETER:
+ case 0x43:
+ position.set(Position.KEY_DEVICE_TEMP, buf.readByte());
+ break;
+ case 0x44:
+ position.set(Position.KEY_ACCELERATION, buf.readUnsignedInt());
+ break;
+ case 0x45:
+ position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
+ break;
+ case 0x46:
+ position.set(Position.KEY_INPUT, buf.readUnsignedShort());
+ break;
+ case 0xd4:
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
break;
-
- case TAG_CAN:
+ case 0xc1:
position.set(Position.KEY_FUEL, buf.readUnsignedByte() * 0.4);
position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte() - 40);
position.set(Position.KEY_RPM, buf.readUnsignedShort() * 0.125);
break;
-
- case TAG_ADC0:
+ case 0x50:
position.set(Position.PREFIX_ADC + 0, buf.readUnsignedShort());
break;
-
- case TAG_ADC1:
+ case 0x51:
position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
break;
-
- case TAG_ADC2:
+ case 0x52:
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
break;
-
- case TAG_ADC3:
+ case 0x53:
position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShort());
break;
-
- case TAG_ARRAY:
- buf.skipBytes(buf.readUnsignedByte());
+ case 0xe2:
+ position.set("userData", buf.readUnsignedInt());
+ break;
+ case 0xea:
+ position.set("userDataArray", ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte())));
break;
-
default:
buf.skipBytes(getTagLength(tag));
break;
-
}
}
if (hasLocation && position.getFixTime() != null) {
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index ef434b779..4103ebba6 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -387,8 +387,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set("deviceType", parser.next());
- position.set("firmwareVersion", parser.nextInt(16));
- position.set("hardwareVersion", parser.nextInt(16));
+ position.set(Position.KEY_VERSION_FW, parser.nextInt(16));
+ position.set(Position.KEY_VERSION_HW, parser.nextInt(16));
DateBuilder dateBuilder = new DateBuilder()
.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index 94d12e989..96f745917 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -64,7 +64,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
.number("(d+);") // course
.number("(d+);") // altitude
.number("(d+.d+)") // hdop
- .number("(?:;d+.d+)?") // vdop
+ .number(";(d+.d+)").optional() // vdop
.expression(",?")
.groupEnd()
.groupBegin()
@@ -154,7 +154,8 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.setAltitude(parser.nextDouble());
- position.set(Position.KEY_HDOP, parser.next());
+ position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_VDOP, parser.nextDouble());
if (parser.hasNext(5)) {
position.setNetwork(new Network(CellTower.from(
diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java
index 7cd0b37f2..97e980290 100644
--- a/src/org/traccar/protocol/HaicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java
@@ -72,7 +72,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_VERSION, parser.next());
+ position.set(Position.KEY_VERSION_FW, parser.next());
DateBuilder dateBuilder = new DateBuilder()
.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
diff --git a/src/org/traccar/protocol/IdplProtocol.java b/src/org/traccar/protocol/IdplProtocol.java
index a954397cd..f90d3fe7f 100644
--- a/src/org/traccar/protocol/IdplProtocol.java
+++ b/src/org/traccar/protocol/IdplProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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.
@@ -28,7 +28,7 @@ import org.traccar.TrackerServer;
public class IdplProtocol extends BaseProtocol {
public IdplProtocol() {
- super("ldpl");
+ super("idpl");
}
@Override
diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java
index 09a3db9bd..719314f28 100644
--- a/src/org/traccar/protocol/IdplProtocolDecoder.java
+++ b/src/org/traccar/protocol/IdplProtocolDecoder.java
@@ -106,7 +106,7 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_OUTPUT, parser.nextInt());
position.set(Position.PREFIX_ADC + 1, parser.nextInt());
position.set(Position.PREFIX_ADC + 2, parser.nextInt());
- position.set(Position.KEY_VERSION, parser.next());
+ position.set(Position.KEY_VERSION_FW, parser.next());
position.set(Position.KEY_ARCHIVE, parser.next().equals("R"));
parser.next(); // checksum
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index 0c3d8ee51..1c88a8b9d 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 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.
@@ -93,24 +93,42 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(BcdUtil.readCoordinate(buf));
position.setSpeed(UnitsConverter.knotsFromKph(BcdUtil.readInteger(buf, 4)));
position.setCourse(BcdUtil.readInteger(buf, 4));
+ position.setValid((buf.readUnsignedByte() & 0x80) != 0);
- int flags = buf.readUnsignedByte();
- position.setValid((flags & 0x80) != 0);
+ if (type != MSG_ALARM) {
- if (type == MSG_ALARM) {
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ position.set(Position.KEY_HDOP, buf.readUnsignedByte());
+ position.set(Position.KEY_VDOP, buf.readUnsignedByte());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- buf.skipBytes(2);
+ buf.skipBytes(5); // other location data
- } else {
+ if (type == MSG_PERIPHERAL) {
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ buf.readUnsignedShort(); // data length
- buf.skipBytes(4); // status
- buf.skipBytes(8); // other
+ int dataType = buf.readUnsignedByte();
- }
+ buf.readUnsignedByte(); // content length
- // parse extra data
+ switch (dataType) {
+ case 0x01:
+ position.set(Position.KEY_FUEL,
+ buf.readUnsignedByte() * 100 + buf.readUnsignedByte());
+ break;
+ case 0x02:
+ position.set(Position.PREFIX_TEMP + 1,
+ buf.readUnsignedByte() * 100 + buf.readUnsignedByte());
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ }
return position;
diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java
index d10f754e9..9538053b6 100644
--- a/src/org/traccar/protocol/OigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OigoProtocolDecoder.java
@@ -208,7 +208,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
int index = buf.readUnsignedByte();
- position.set(Position.KEY_VERSION, buf.readUnsignedByte());
+ position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_ODOMETER, (long) (buf.readUnsignedInt() * 1609.34));
diff --git a/src/org/traccar/protocol/PricolProtocol.java b/src/org/traccar/protocol/PricolProtocol.java
index 924c7c1d6..0005dc3c1 100644
--- a/src/org/traccar/protocol/PricolProtocol.java
+++ b/src/org/traccar/protocol/PricolProtocol.java
@@ -15,6 +15,7 @@
*/
package org.traccar.protocol;
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
@@ -38,6 +39,12 @@ public class PricolProtocol extends BaseProtocol {
pipeline.addLast("objectDecoder", new PricolProtocolDecoder(PricolProtocol.this));
}
});
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new PricolProtocolDecoder(PricolProtocol.this));
+ }
+ });
}
}
diff --git a/src/org/traccar/protocol/PricolProtocolDecoder.java b/src/org/traccar/protocol/PricolProtocolDecoder.java
index 52b68cca6..3313afa22 100644
--- a/src/org/traccar/protocol/PricolProtocolDecoder.java
+++ b/src/org/traccar/protocol/PricolProtocolDecoder.java
@@ -87,7 +87,7 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RPM, buf.readUnsignedShort());
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer("ACK", StandardCharsets.US_ASCII));
+ channel.write(ChannelBuffers.copiedBuffer("ACK", StandardCharsets.US_ASCII), remoteAddress);
}
return position;
diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
index fa789510e..87e55ea86 100644
--- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
@@ -112,7 +112,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.nextInt());
position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
position.set(Position.KEY_FUEL, parser.nextInt());
- position.set("accel", parser.nextInt() == 1);
+ position.set(Position.KEY_ACCELERATION, parser.nextInt() == 1);
position.set(Position.KEY_OUTPUT, parser.nextInt() + parser.nextInt() << 1);
}
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index d081cb901..55d5c224a 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -65,7 +65,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_VERSION, values[index++]);
+ position.set(Position.KEY_VERSION_FW, values[index++]);
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
@@ -116,7 +116,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
index += 1; // model
}
- position.set(Position.KEY_VERSION, values[index++]);
+ position.set(Position.KEY_VERSION_FW, values[index++]);
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 87cc72814..993029ddb 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -89,7 +89,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV");
break;
case 70:
- position.set("pcbTemp", (length == 4 ? buf.readInt() : buf.readShort()) * 0.1);
+ position.set(Position.KEY_DEVICE_TEMP, (length == 4 ? buf.readInt() : buf.readShort()) * 0.1);
break;
case 72:
position.set(Position.PREFIX_TEMP + 1, buf.readInt() * 0.1);
diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java
index 3b73a1516..40ce04c5b 100644
--- a/src/org/traccar/protocol/TmgProtocolDecoder.java
+++ b/src/org/traccar/protocol/TmgProtocolDecoder.java
@@ -18,6 +18,7 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -60,6 +61,11 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
.expression("([01]+),") // input
.expression("([01]+),") // output
.expression("[01]+,") // temper status
+ .number("(d+.?d*)[^,]*,") // adc1
+ .number("(d+.?d*)[^,]*,") // adc2
+ .number("d+.?d*,") // trip meter
+ .expression("([^,]*),") // software version
+ .expression("([^,]*),").optional() // rfid
.any()
.compile();
@@ -128,8 +134,21 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
position.set(Position.KEY_BATTERY, parser.nextDouble());
position.set(Position.KEY_POWER, parser.nextDouble());
- position.set(Position.KEY_INPUT, parser.nextInt(2));
- position.set(Position.KEY_OUTPUT, parser.nextInt(2));
+
+ int input = parser.nextInt(2);
+ int output = parser.nextInt(2);
+
+ if (!BitUtil.check(input, 0)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ }
+
+ position.set(Position.KEY_INPUT, input);
+ position.set(Position.KEY_OUTPUT, output);
+
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
+ position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
+ position.set(Position.KEY_VERSION_FW, parser.next());
+ position.set(Position.KEY_RFID, parser.next());
return position;
}
diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
index 57003e832..d1bd1398b 100644
--- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
@@ -125,7 +125,7 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- position.set(Position.KEY_VERSION, parser.next());
+ position.set(Position.KEY_VERSION_FW, parser.next());
parser.next(); // hardware version
return position;