aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-01 21:31:44 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-01 21:31:44 -0700
commit08b950ea73ba142b5681aad4b208755db540cdb0 (patch)
tree7c7860ccb8619195135978858b87e436d125f134 /src
parent59416923dcb3a756eaf532cc4259f2f6625c0762 (diff)
downloadtraccar-server-08b950ea73ba142b5681aad4b208755db540cdb0.tar.gz
traccar-server-08b950ea73ba142b5681aad4b208755db540cdb0.tar.bz2
traccar-server-08b950ea73ba142b5681aad4b208755db540cdb0.zip
Send correct alarm response
Diffstat (limited to 'src')
-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;
}