diff options
Diffstat (limited to 'src/org/traccar/protocol/NoranProtocolEncoder.java')
-rw-r--r-- | src/org/traccar/protocol/NoranProtocolEncoder.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/NoranProtocolEncoder.java b/src/org/traccar/protocol/NoranProtocolEncoder.java index 25b510a73..cb25cc94b 100644 --- a/src/org/traccar/protocol/NoranProtocolEncoder.java +++ b/src/org/traccar/protocol/NoranProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,32 +15,29 @@ */ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Log; import org.traccar.model.Command; -import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; public class NoranProtocolEncoder extends BaseProtocolEncoder { - private ChannelBuffer encodeContent(String content) { + private ByteBuf encodeContent(String content) { - ChannelBuffer buf = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, 12 + 56); + ByteBuf buf = Unpooled.buffer(12 + 56); - buf.writeBytes( - ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n*KW", StandardCharsets.US_ASCII)); + buf.writeBytes(Unpooled.copiedBuffer("\r\n*KW", StandardCharsets.US_ASCII)); buf.writeByte(0); - buf.writeShort(buf.capacity()); - buf.writeShort(NoranProtocolDecoder.MSG_CONTROL); + buf.writeShortLE(buf.capacity()); + buf.writeShortLE(NoranProtocolDecoder.MSG_CONTROL); buf.writeInt(0); // gis ip - buf.writeShort(0); // gis port + buf.writeShortLE(0); // gis port buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII)); buf.writerIndex(buf.writerIndex() + 50 - content.length()); - buf.writeBytes( - ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n", StandardCharsets.US_ASCII)); + buf.writeBytes(Unpooled.copiedBuffer("\r\n", StandardCharsets.US_ASCII)); return buf; } |