aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/EgtsProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/T800xProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolEncoder.java6
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java20
6 files changed, 31 insertions, 23 deletions
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index db0ec8c66..f48757a4f 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -100,7 +100,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, BitUtil.to(status, 4));
position.set(Position.KEY_HDOP, BitUtil.from(status, 4));
- position.setCourse(buf.readUnsignedByte());
+ position.setCourse(buf.readUnsignedByte() * 2);
position.setAltitude(buf.readUnsignedShort());
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java
index 420701e6c..6ac7af440 100644
--- a/src/org/traccar/protocol/EgtsProtocolDecoder.java
+++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java
@@ -81,9 +81,13 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
data.writeBytes(content);
ChannelBuffer record = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ if (packetType == PT_RESPONSE) {
+ record.writeShort(index);
+ record.writeByte(0); // success
+ }
record.writeShort(data.readableBytes());
- record.writeShort(index);
- record.writeByte(1 << 6); // flags
+ record.writeShort(0);
+ record.writeByte(0); // flags (possibly 1 << 6)
record.writeByte(serviceType);
record.writeByte(serviceType);
record.writeBytes(data);
@@ -113,6 +117,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
+ int index = buf.getUnsignedShort(buf.readerIndex() + 5 + 2);
buf.skipBytes(buf.getUnsignedByte(buf.readerIndex() + 3));
List<Position> positions = new LinkedList<>();
@@ -120,7 +125,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() > 2) {
int length = buf.readUnsignedShort();
- int index = buf.readUnsignedShort();
+ int recordIndex = buf.readUnsignedShort();
int recordFlags = buf.readUnsignedByte();
if (BitUtil.check(recordFlags, 0)) {
@@ -146,7 +151,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
}
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
- response.writeShort(index);
+ response.writeShort(recordIndex);
response.writeByte(0); // success
sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response);
@@ -186,7 +191,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
response.writeByte(0); // success
- sendResponse(channel, PT_APPDATA, index, serviceType, MSG_RESULT_CODE, response);
+ sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response);
} else if (type == MSG_POS_DATA) {
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index be3cb5f67..dfe0d541f 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -53,7 +53,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.number(",(d+)") // imei
.expression(",([01])") // ignition
.number(",(d+)") // fuel
- .number(",(d+)").optional(5) // battery
+ .number(",(d+)").optional(7) // battery
.number("((?:,d+)+)?") // parameters
.any()
.compile();
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java
index a6a647f22..7bc780c83 100644
--- a/src/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/org/traccar/protocol/T800xProtocolDecoder.java
@@ -49,11 +49,10 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
return ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes).readFloat();
}
- private void sendResponse(Channel channel, int type, ChannelBuffer imei) {
+ private void sendResponse(Channel channel, short header, int type, ChannelBuffer imei) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(15);
- response.writeByte(0x23);
- response.writeByte(0x23); // header
+ response.writeShort(header);
response.writeByte(type);
response.writeShort(response.capacity()); // length
response.writeShort(0x0001); // index
@@ -87,7 +86,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
- buf.skipBytes(2);
+ short header = buf.readShort();
int type = buf.readUnsignedByte();
buf.readUnsignedShort(); // length
int index = buf.readUnsignedShort();
@@ -100,7 +99,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
}
if (type == MSG_LOGIN || type == MSG_ALARM || type == MSG_HEARTBEAT) {
- sendResponse(channel, type, imei);
+ sendResponse(channel, header, type, imei);
}
if (type == MSG_GPS || type == MSG_ALARM) {
diff --git a/src/org/traccar/protocol/Tk103ProtocolEncoder.java b/src/org/traccar/protocol/Tk103ProtocolEncoder.java
index 3ec562cc3..d64c85c2c 100644
--- a/src/org/traccar/protocol/Tk103ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolEncoder.java
@@ -47,6 +47,8 @@ public class Tk103ProtocolEncoder extends StringProtocolEncoder {
if (alternative) {
switch (command.getType()) {
+ case Command.TYPE_CUSTOM:
+ return formatAlt(command, "{%s}", Command.KEY_DATA);
case Command.TYPE_GET_VERSION:
return formatAlt(command, "*about*");
case Command.TYPE_REBOOT_DEVICE:
@@ -57,8 +59,6 @@ public class Tk103ProtocolEncoder extends StringProtocolEncoder {
return formatAlt(command, "*routetrack*99*");
case Command.TYPE_POSITION_STOP:
return formatAlt(command, "*routetrackoff*");
- case Command.TYPE_CUSTOM:
- return formatAlt(command, "{%s}", Command.KEY_DATA);
case Command.TYPE_GET_DEVICE_STATUS:
return formatAlt(command, "*status*");
case Command.TYPE_IDENTIFICATION:
@@ -80,6 +80,8 @@ public class Tk103ProtocolEncoder extends StringProtocolEncoder {
}
} else {
switch (command.getType()) {
+ case Command.TYPE_CUSTOM:
+ return formatCommand(command, "({%s}{%s})", Command.KEY_UNIQUE_ID, Command.KEY_DATA);
case Command.TYPE_GET_VERSION:
return formatCommand(command, "({%s}AP07)", Command.KEY_UNIQUE_ID);
case Command.TYPE_REBOOT_DEVICE:
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 06a1fbc41..d8943abd5 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -245,12 +245,13 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
int io = parser.nextBinInt();
if (pattern == PATTERN1) {
- if (BitUtil.check(io, 0)) {
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- }
- for (int i = 1; i <= 4; i++) {
- position.set(Position.PREFIX_IN + i, BitUtil.check(io, 3 + i));
- }
+ position.set(Position.KEY_ALARM, BitUtil.check(io, 0) ? Position.ALARM_SOS : null);
+ position.set(Position.PREFIX_IN + 3, BitUtil.check(io, 4));
+ position.set(Position.PREFIX_IN + 4, BitUtil.check(io, 5));
+ position.set(Position.PREFIX_IN + 1, BitUtil.check(io, 6));
+ position.set(Position.PREFIX_IN + 2, BitUtil.check(io, 7));
+ position.set(Position.PREFIX_OUT + 1, BitUtil.check(io, 8));
+ position.set(Position.PREFIX_OUT + 2, BitUtil.check(io, 9));
position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.01);
} else {
position.set(Position.KEY_ANTENNA, BitUtil.check(io, 0));
@@ -258,11 +259,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
for (int i = 1; i <= 6; i++) {
position.set(Position.PREFIX_IN + i, BitUtil.check(io, 1 + i));
}
+ for (int i = 1; i <= 4; i++) {
+ position.set(Position.PREFIX_OUT + i, BitUtil.check(io, 7 + i));
+ }
position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
}
- for (int i = 1; i <= 4; i++) {
- position.set(Position.PREFIX_OUT + i, BitUtil.check(io, 7 + i));
- }
+
position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());