aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/T800xProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/T800xProtocolDecoder.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
index dfb286257..b6dea49e5 100644
--- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
@@ -45,7 +45,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ALARM = 0x04;
public static final int MSG_COMMAND = 0x81;
- private void sendResponse(Channel channel, short header, int type, int index, ByteBuf imei) {
+ private void sendResponse(Channel channel, short header, int type, int index, ByteBuf imei, int alarm) {
if (channel != null) {
ByteBuf response = Unpooled.buffer(15);
response.writeShort(header);
@@ -53,11 +53,14 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
response.writeShort(response.capacity()); // length
response.writeShort(index);
response.writeBytes(imei);
+ if (alarm > 0) {
+ response.writeByte(alarm);
+ }
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
- private String decodeAlarm(short value) {
+ private String decodeAlarm(int value) {
switch (value) {
case 1:
return Position.ALARM_POWER_CUT;
@@ -98,6 +101,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
int index = buf.readUnsignedShort();
ByteBuf imei = buf.readSlice(8);
+ int alarm = 0;
DeviceSession deviceSession = getDeviceSession(
channel, remoteAddress, ByteBufUtil.hexDump(imei).substring(1));
@@ -105,8 +109,6 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- sendResponse(channel, header, type, index, imei);
-
if (type == MSG_GPS || type == MSG_ALARM) {
Position position = new Position(getProtocolName());
@@ -137,7 +139,8 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
- position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
+ alarm = buf.readUnsignedByte();
+ position.set(Position.KEY_ALARM, decodeAlarm(alarm));
buf.readUnsignedByte(); // reserved
@@ -189,10 +192,14 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, BcdUtil.readInteger(buf, 4) * 0.01);
}
+ sendResponse(channel, header, type, index, imei, alarm);
+
return position;
}
+ sendResponse(channel, header, type, index, imei, alarm);
+
return null;
}