diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-08 11:07:43 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-08 11:07:43 +1200 |
commit | 4d9187e2ee98eee17d4adbcb84379e2c68fe2bcd (patch) | |
tree | 0751e189301c050e3a66ef25326190ea54fc7f92 /src/org/traccar/protocol/NoranProtocolEncoder.java | |
parent | e26b25c7c35cb99f3e0fb114bcedd76f090e0c3b (diff) | |
download | trackermap-server-4d9187e2ee98eee17d4adbcb84379e2c68fe2bcd.tar.gz trackermap-server-4d9187e2ee98eee17d4adbcb84379e2c68fe2bcd.tar.bz2 trackermap-server-4d9187e2ee98eee17d4adbcb84379e2c68fe2bcd.zip |
Migrate L, M, N protocols
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; } |