aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/T55ProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolEncoderTest.java14
9 files changed, 54 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());
diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
index bbcead2d0..b369ab41b 100644
--- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -116,6 +116,9 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
decoder.setProtocolType(1);
verifyPosition(decoder, text(
+ "ST910;Location;907510186;552;20180504;23:15:45;3af54e5331;+19.301833;-099.190657;000.246;000.00;1;28462;80;1;0;0423;02;334;05;-215;20051;1;4;100"));
+
+ verifyPosition(decoder, text(
"ST910;Alert;485195;20170409;22:37:41;3be0133057;+24.882410;-107.509152;000.070;000.00;1;286734;72;02;295;05;-415;4912;255;10;10"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/T55ProtocolDecoderTest.java b/test/org/traccar/protocol/T55ProtocolDecoderTest.java
index ec699f111..298540e3b 100644
--- a/test/org/traccar/protocol/T55ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/T55ProtocolDecoderTest.java
@@ -20,6 +20,12 @@ public class T55ProtocolDecoderTest extends ProtocolTest {
"358244017671308"));
verifyPosition(decoder, text(
+ "$GPGGA,082350.000,5355.0314,N,01044.1271,E,1,10,0.7,-46.0,M,0.0,M,0.0,0000"));
+
+ verifyPosition(decoder, text(
+ "$GPRMC,082350.000,A,5355.0314,N,01044.1271,E,26.20,184.27,080518,,"));
+
+ verifyPosition(decoder, text(
"$GPRMC,192350.000,V,0000.0000,N,00000.0000,E,,,110318,,*12"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
index 25968a0fe..34b2acf86 100644
--- a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
@@ -221,6 +221,20 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
}
@Test
+ public void testEncodeCustom() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_CUSTOM);
+ command.set(Command.KEY_DATA, "AA00");
+
+ assertEquals("(123456789012345AA00)", encoder.encodeCommand(command));
+
+ }
+
+ @Test
public void testEncodeCustomAlternative() throws Exception {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);