From fe1ed7c8087d24cf5e853dc5ef942cce16149248 Mon Sep 17 00:00:00 2001 From: Ankit Tater Date: Sat, 24 Oct 2015 15:00:14 +0530 Subject: T880X protocol Response to Alarm Packet --- src/org/traccar/protocol/T800XProtocolDecoder.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/protocol') 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; } } -- cgit v1.2.3