diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-05-25 13:41:03 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-05-25 13:41:03 -0700 |
commit | 10ee656e44dcbba7f87989ecc0e2ddfcf2c12d4a (patch) | |
tree | 291eb9100c6fb79184bbbb97b8cd27e4d213c69c /src/org/traccar/protocol/AutoFonProtocolDecoder.java | |
parent | 267999c33a63356dd9aad0628e39548aab249a80 (diff) | |
download | trackermap-server-10ee656e44dcbba7f87989ecc0e2ddfcf2c12d4a.tar.gz trackermap-server-10ee656e44dcbba7f87989ecc0e2ddfcf2c12d4a.tar.bz2 trackermap-server-10ee656e44dcbba7f87989ecc0e2ddfcf2c12d4a.zip |
Fix AutoFon old protocol response
Diffstat (limited to 'src/org/traccar/protocol/AutoFonProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AutoFonProtocolDecoder.java | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index a633005b4..011a6542b 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -120,10 +120,12 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { int type = buf.readUnsignedByte(); - if (type == MSG_LOGIN) { + if (type == MSG_LOGIN || type == MSG_45_LOGIN) { - buf.readUnsignedByte(); // hardware version - buf.readUnsignedByte(); // software version + if (type == MSG_LOGIN) { + buf.readUnsignedByte(); // hardware version + buf.readUnsignedByte(); // software version + } String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1); if (!identify(imei, channel, remoteAddress)) { @@ -131,7 +133,10 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { } if (channel != null) { - channel.write(ChannelBuffers.wrappedBuffer(new byte[] {buf.readByte()})); + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + response.writeBytes("resp_crc=".getBytes(StandardCharsets.US_ASCII)); + response.writeByte(buf.getByte(buf.writerIndex() - 1)); + channel.write(response); } } else if (type == MSG_LOCATION) { @@ -150,20 +155,6 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { return positions; - } else if (type == MSG_45_LOGIN) { - - String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1); - if (!identify(imei, channel, remoteAddress)) { - return null; - } - - if (channel != null) { - ChannelBuffer response = ChannelBuffers.dynamicBuffer(); - response.writeBytes("resp_crc=".getBytes(StandardCharsets.US_ASCII)); - response.writeByte(buf.getByte(buf.writerIndex() - 1)); - channel.write(response); - } - } else if (type == MSG_45_LOCATION) { Position position = new Position(); |