aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnkit Tater <ankit@isuraksha.in>2015-10-24 15:00:14 +0530
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-01 18:20:59 +1300
commitfe1ed7c8087d24cf5e853dc5ef942cce16149248 (patch)
tree922c6119fb4ccba65533010f6535e33c60e3d8b6 /src/org/traccar
parent0858303eedc1cfdc22297c3e8c013f31e0df684e (diff)
downloadtrackermap-server-fe1ed7c8087d24cf5e853dc5ef942cce16149248.tar.gz
trackermap-server-fe1ed7c8087d24cf5e853dc5ef942cce16149248.tar.bz2
trackermap-server-fe1ed7c8087d24cf5e853dc5ef942cce16149248.zip
T880X protocol Response to Alarm Packet
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/T800XProtocolDecoder.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/T800XProtocolDecoder.java b/src/org/traccar/protocol/T800XProtocolDecoder.java
index aff8d013a..ecd021547 100644
--- a/src/org/traccar/protocol/T800XProtocolDecoder.java
+++ b/src/org/traccar/protocol/T800XProtocolDecoder.java
@@ -54,22 +54,24 @@ public class T800XProtocolDecoder extends BaseProtocolDecoder {
private Long deviceId;
- private void sendResponse(Channel channel, int type, int index, String imei) {
+ private void sendLoginResponse(Channel channel, int type, int index, String imei) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.buffer(7+imei.getBytes().length);
+ int length=7+(imei.length()/2+1);
+ ChannelBuffer response = ChannelBuffers.buffer(length);
response.writeByte(0x23);
response.writeByte(0x23); // header
response.writeByte(type);
response.writeByte(0x00);
- response.writeByte(0x0F); // length
- response.writeByte(0x00);
- response.writeByte(0x01); //index
+ response.writeByte(length); // length
+ response.writeShort(0x0001);//imei
//IMEI
response.writeBytes(ChannelBufferTools.convertHexString("0" + imei));
channel.write(response);
}
}
+
+
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -91,7 +93,7 @@ public class T800XProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGIN) {
try {
deviceId = getDataManager().getDeviceByImei(imei).getId();
- sendResponse(channel, type, index, imei); // send login response
+ sendLoginResponse(channel, type, index, imei); // send login response
return null;
} catch (Exception error) {
Log.warning("Unknown device - " + imei);
@@ -149,8 +151,8 @@ public class T800XProtocolDecoder extends BaseProtocolDecoder {
extendedInfo.set(statusType,true);
if(type == MSG_ALARM)
{
- Log.debug("ALARM"+statusType);
- sendResponse(channel,type,index,imei+alarmData);
+ Log.debug("ALARM : "+statusType);
+ sendLoginResponse(channel, type, index, imei + alarmData);
}
// Reserve
@@ -207,6 +209,7 @@ public class T800XProtocolDecoder extends BaseProtocolDecoder {
Status status = new Status();
status.setDate(time.getTime());
status.setDeviceid(deviceId);
+ status.setVoltage(getBatteryPerc(batteryVoltage));
status.setStatusType(statusType);
return status;
@@ -219,7 +222,7 @@ public class T800XProtocolDecoder extends BaseProtocolDecoder {
Status status = new Status();
status.setDate(dateFormatLocal.parse(dateFormatGmt.format(new Date())));
status.setDeviceid(deviceId);
- sendResponse(channel, type, index, imei);
+ sendLoginResponse(channel, type, index, imei);
return status;
}
}