aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/T800xProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java20
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java3
3 files changed, 18 insertions, 14 deletions
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/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(